Nil is an object pointer is empty, nil is a class pointer is empty, NULL is the basic data type is empty. These can be understood as nil,nil, the difference between null.
IOS Shear Plate
Uipasteboard *pasteboard = [Uipasteboard Generalpasteboard];
Pasteboard.string = @ "The string to be assigned to the Clipboard";
1 ID
you can pass any message to the ID, but if the ID does not support this message it will return a run-time exception, usually the message "Unrecognisedselector sent to instance to XXX". 2 SELSEL types can also be created with the nsselectorfromstring (NSString *) function 3Nil is used to assign values to objects,NULL is assigned to any pointer, null and nil are not interchangeable,Nil is used for class pointer assignment, while Nsnull is used for collection assignment.such as:A.If (object = nil) {}//Judgment object is empty B.uiviewcontroller *controller = [Nsarray objectatindex:i];//to determine if an array element is emptyif ((NSNull *) controller = = [NSNull null]) {//...} c.nsstring *userid = [nsdictionary objectforkey:@ "UserId"];//determines whether the element of the Dictionary object is emptyif (userId = = [NSNull null]) {}4 preprocessing MacrosA turn off debug information:#define DLOG ();b
print file name, line number, function details, function name information,
NSLog (@ "%s%d%s", __file__, __line__,__pretty_function__,__function__);#ifdef DEBUG# define DLOG (FMT,...) NSLog (@ "%s [line%d]" FMT), __pretty_function__,__line__,# #__VA_ARGS__);#else# define DLOG (...);#endif 5 Auto-release pool (Autoreleasepool)in the program, when there are a large number of automatic variables need to be managed, you need to create nsautoreleasepool to manage;when creating a thread or using nsoperation, you also need to create a separate nsautoreasepool to manage the threads;In addition, overloading the didreceivememorywarning () function is a good programming habit; 6 Program Execution Flowso the process should look like this:
(loadview/nib file) to load view into memory-->viewdidload function to further initialize these view--> when memory is low, call the Viewdidunload function to release views
-When you need to use view, go back to the first step
so Loop7 ASIHTTPRequesthttp://www.dreamingwish.com/dream-2011/apples-third-party-development-libraries-asihttprequest.html 8 Determine if a string is emptyif (str = = nil)if ([str length] = = 0) 9 Working with numeric objectsA. Nsinteger-------intnsnumber *numobj = [NSNumber numberwithint:2];Nsinteger myinteger = [Numobj integervalue];int a = [Myinteger intvalue]; B. Floating-point values use CGFloat. Nsdecimalnumber Objects for processingnsdecimalnumber *mydecimalobj = [[Nsdecimalnumber allo] initwithstring:@ "23.39"];NSLog (@ "Mydecimalobj Doublevalue =%6.3f", [Mydecimalobj Doublevalue]);cgfloat mycgfloatvalue = 43.4;nsdecimalnumber *myotherdecimalobj = [[Nsdecimalnumber alloc] initwithfloat:mycgfloatvalue];NSLog (@ "Myotherdecimalobj doublevalue=%6.3f", [Myotherdecimalobj Doublevalue]);10 Processing Date Time NSDateA. Get the current date time code as followsnsdate *datetoday = [NSDate date];NSDateFormatter *df = [[NSDateFormatter alloc] init];[DF setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];Nslocale *locale = [[Nslocale alloc] initwithlocalidentifier:@ "en_US"];[DF Setlocale:locale];B. Generate the Date object from the string as followsnsstring *mydatestring = @ "2009-09-15 18:30:00";nsdate *mydate = [DF datefromstring:mydatestring]; c. Code for date comparisonswitch ([datetoday compare:mydate]) {Case Nsorderedsame:Break ;Case nsorderedascending:Break ;Case nsordereddescending:Break ;Default:Break ;} 11 Common Array Operationsa determines whether an object is contained in an array-(BOOL) Containsobject: (ID) anobjectb Add, insert elementNsmutablearray *array = [Nsmutablearray alloc] init];[Array addobject:anobject];[Array insertobject:anobject atindex:2];[Array Addobjectsfromarray:anotherarray];C Gets the index value of an elementNsinteger idx = [array indexofobject:anobject];d updating array elements[Mutablearray replaceobjectatindex:idx withobject:[nsnumber Numberwithint:9]]e Array Traversal1. Using EnumerationsFor (NSString *str in array) {}2 using Nsenumeratornsenumerator *enumerator = [array objectenumerator];ID obj;For (obj = = [Enumerator nextobject]) {}3. Using A For loopfor (int i = 0; i < [array count]; i++) {[Array objectatindex:i];} 12 Sorting string ArraysA. Nsarray *sortedarray = [Array sortedarrayusingselector: @selector (caseinsensitivecompare:)];B. Nscountedset *cset = [[Nscountedset alloc] initwitharray:array];Nsarray *sorted = [[Cset allobjects] Sortedarrayusingselector: @selector (compare:)]; a method of generating random numbers in OCSrandom (Time (NULL));arc4random ()%n; 14 Array Map operation (-makeobjectsperformselector ())the function can act on all elements of an array, such as;Nsarray *fighters = ...;[Fighters Makeobjectsperformselector: @selector (fly:)]; -(void) Fly: (ID) Sender {} 15 Sorting Object Array (using Nssortdescriptor) 16 Object array filtering (using Nspredicate)nspredicate *apredicate = [nspredicate predicatewithformat:@ "Self.lastname beginswith[c] ' a '"];Nsarray *array = [array filteredarrayusingpredicate:apredicate]; 17 deleting elements in an arrayA more secure way to put elements that satisfy a condition into a temporary array and return the array with the following code:-(Nsarray *) Filterpersonwithlastname: (NSString *) FilterText {Person *person = [Person alloc] init];Nsmutablearray *personlist = [person creattemprarylist];NSLog (@ "before");Nsmutablearray *personstoremove = [Nsmutablearray array];For (person *person in personlist) {if (FilterText && [FilterText rangeOfString:person.laseName options:nsliteralsearch | Nscaseinsensitivesearch].length = = 0)[Personstoremove Addobject:person];}[Personlist Removeobjectsinarray:personstoremove];}
iOS Development understanding Nil,nil, NULL