Using the Protocol to delegate tasks is a process that declares certain methods and attributes and stores them in the Entity document. The Protocol is like some norms, and the classes of practice protocols must comply with these norms. Create the Protocol xcode --> File --> New File --> Cocoa Touch --> Objective-C Protocol --> Next --> Protocol name (eg: PersonProtocol) --> Save actual declaration Protocol: # import <Foundation/Foundation. h> @ protocol PersonProtocol <NSObject> @ optional @ property (nonamotic, strong) NSString * firstName; @ property (nonamotic, strong) NSString * lastName; @ required // required methods and attributes @ property (nonamotic, unsafe_unretatined) NSUInteger arg;-(void) breathe; @ end creates a Fathe R class, implementation protocol # import <Foundation/Foundation. h> # import "PersonProtocol. h "@ interface Father: NSObject <PersonProtocol>-(void) breathe; @ end //. m requires an instance method. The keyword @ required in the protocol explicitly specifies the required attributes and methods. @ Optional can be used in practice or without the need to use monitoring instance methods or class methods for effective use of the environment: the SDK you developed is the latest version, but you want to support devices that execute the old ios sdk. Use NSObject's instancesRespondToSelector: Class Method to check whether the specified selector exists in the class instance. To determine whether a Class responds to its own class method, use respondsToSelector: class method. You can use the same method for detection. In the instance method of an instance, there are two important concepts about the iOS SDK through the instancesRespondToSelector: NSObject class method. Remember: Base SDK (Base SDK) this SDK is used to compile applications. It may be the latest and largest SDK and can access all new APIs. The Deployment SDK/Target (Deployment SDK) allows you to specify the device SDK version you want to compile and run. As a matter of fact, compiling an application is based on the Base SDK and Depolyment SDK. For example: NSMutableArray * array = [[NSMutableArray alloc] initWithObjects: @ "Item 1", @ "Item 4", @ "Item 2", @ "Item 5 ", @ "Item 3", nil]; NSLog (@ "Array = % @", array); if ([NSArray instancesRespondToSelector: @ selector (sortUsingComparator :)]) {/* use sortUsingComparator: instance method to arrange arrays */} else if ([NSArray instancesRespondToSelector: @ selector (sortUsingFunction: context :)]) {/* use sortUsingFunction: context: object method for Array sorting * /} Else {/* handle other situations */} check whether the class can use the environment during running: you are using the latest SDK, but you are not sure whether it can be used, this is because you cannot determine whether the latest SDK is installed. The NSString and NSMutableString NSString types used by the string cannot be changed. Once the NSString class is created, the content cannot be modified. The variable string NSMutableString can be modified after it is created. NSString * string = @ "hello world"; NSString * string = [NSString stringWithString: @ "hello world"]; NSMutableString is the same as the string length [string length]; string type conversion: NSString * string = @ "123.456"; NSInteger integerOfString = [string integerValue]; // 123 CGFloat floatOfString = [string floatValue]; // 123.456001 Double doubleOfString = [string doubleValue]; // search for the NSString * one = @ "hello world"; NSString * two = in the 123.456.000 string @ "Hello"; nsange range = [one rangeOfString: two]; if (range. location = NSNotFound) {/* Coule NOT find nedle in haystack */} else {NSLog (@ "% @", range. location);} The number NSNumber class is used to process numbers in an object-oriented manner. NSInteger signed number (positive or negative) NSUInteger unsigned number (positive and 0) CGFloat and double operation floating point number. NumberWithInteger: encapsulate an integer value into an NSNumber instance numberWithUnsignedInteger: encapsulate an unsigned integer value into an NSNumber instance numberWithFloat: encapsulate a floating point number into an NSNumber instance numberWithDouble: encapsulate a number of the double type into an NSNumber instance. The following methods are used to extract pure numbers from an NSNumber instance: integerValue/unsignedIntegerValue/floatValue/doubleValue and a string comparison method: NSNumber * unsighedNumber = [NSNumber numberWithUnsignedInteger: 123456]; NSString * numberInString = [NSString stringWithFormat: @ "% lu ",( Unsigned long) [unsignedNumber unsignedIntegerValue]; NSLog (@ "% @", numberInString); array allocation and use: NSArray and NSMutableArray NSArray * array = [NSArray alloc] direction: @ "one", @ "two", @ "three", nil]; automatically released array: NSArray * array = [NSArray arrayWithObjects: @ "one ", @ "two", @ "three", nil]; array length [array count]; added object [array addObject: @ "four"] To the nsmutableArray array; deleted array [array removeObject: @ "four"]; get the object objectAtIndex at the specified position of the array: allocate and use Dictionary allocation is very similar to SetsSets and array. The biggest difference between them is that the same object in sets can only be added once. When you add the same object for the second time, the sets will not be added. AddObject adds the object removeObject to delete objects and quickly traverses all objects in a set. enumerateObjectsUsingBlock: method. For example, [setOfNames enumerateObjectsUsingBlock: ^ (_ strong id obj, BOOL * stop) {if ([obj isKindOfClass: [NSString class]) {NSString * string = (NSString *) obj; if ([string isEqualToString: @ "Kiyosaki") {NSLog (@ "Found % @ in the set", string); * stop = YES ;}}} the nsicationicationcenter sends a notification and publishes a notification through the App to allow other objects to receive the notification and take action, depending on the notification you publish. Use the default notificationcenter's postNotificationName: object: userInfo: instance method in nsicationicationcenter to publish a notification with an object (usually this object activates the notification) and a user information dictionary, the dictionary contains additional information about the entry notification or the object that activates the notification.