Things to remember about iOS using Jspatch

Source: Internet
Author: User

The first code, in order to correct the original code does not display 29th number of bugs, first on the code

1Require (' nsstring ', ' mcdatepicktype ', ' nsmutablearray ', ' UIButton ');2 3DefineClass (' Mmcdatepickview ',{4 5Setdatepickviewselected:function() {6 7 Self.setselectedyearrow (Self.yeararray (). Indexofobject (Self.currentyearstring ()));8 Self.setselecteddayrow (self. Daysarray (). Indexofobject (Self.currentdaystring ()));9 Self.setselectedhourrow (Self.hoursarray (). Indexofobject (Self.currenthourstring ()));TenSelf.setselectedminuterow (Self.minutesarray (). Indexofobject (Nsstring.stringwithformat ("%@ min"), self.currentminutestring () ))); One  A  -     //set year and month -      varMonthandyear = Self.currentyearstring (). Tojs () + ' year ' + self.currentmonthstring (). Tojs () + ' month '; the  -     if(Self.type () = = = 0) { -  -  +          for(vari = 0; I < Self.yeararray (). Count (); i++) { -              +             varJsarray =Self.yeararray (). Tojs (); A             varYear =Jsarray[i]; at             if(Year = =self.currentyearstring (). TOJS ()) { -                  -Self.datepickview (). selectrow_incomponent_animated (i, 0, YES); -  -                  Break; -             } in         } -  to          +     }  -     Else { the  *  $ Self.setselectedmonthrow (Self.yearandmontharray (). Indexofobject (Monthandyear));Panax NotoginsengSelf.datepickview (). selectrow_incomponent_animated (Self.selectedmonthrow (), 0, YES); -         the  +     if(Self.type ()!== 0 && self.type ()!== 1 && self.type ()!== 5) { ASelf.datepickview (). selectrow_incomponent_animated (Self.selecteddayrow (), 1, YES); the     } +  -  $     //Selected Hours $     if(Self.type () = = = 3 | | self.type () = = = 4) { -Self.datepickview (). selectrow_incomponent_animated (Self.selectedhourrow (), 2, YES); -     } the  -     //Selected pointsWuyi     if(Self.type () = = = 4) { theSelf.datepickview (). selectrow_incomponent_animated (Self.selectedminuterow (), 3, YES); -     } Wu  -  About     //Select the custom $     if(Self.type () = = = 5) { -Self.datepickview (). selectrow_incomponent_animated (Self.customerindex (), 0, YES); -     } - } A } +});

Precautions:

1. In the character or array, dictionary operation should be converted to JS string or dictionary, etc.

1 var monthandyear = self.currentyearstring (). Tojs () + ' year ' + self.currentmonthstring (). Tojs () + ' month ';

The above code is correct, Monthandyear is the JS format of the string, the bottom is not right:

var Monthandyear = self.currentyearstring () + ' year ' + self.currentmonthstring () + ' month ';

2. When comparing, using the same type, JS data type and OC is not the same

1 var jsarray = self.yeararray (). Tojs (); 2             var year = jsarray[i]; 3             if (Year = = self.currentyearstring (). Tojs ()) {4                 5                 Self.datepickview (). selectrow_incomponent_animated (i, 0, YES); 6 7                  Break ; 8             }

3.js is a weak type language, does not emphasize the type, OC enumeration in JS does not do,

1 self.type () = = = 0

Finally, it turns the enumeration into a basic data type.

Things to remember about iOS using Jspatch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.