1Person *person1 =[[Person alloc]init];2Person *person2 =[[Person alloc]init];3 4 //private methods in the class can be called, but there is a warning5 [Person1 performselector: @selector (Actiontow)];6[Person1 performselector: @selector (actionone:) Withobject:@"Test"];7 8NSLog (@"address of Person1:%p", Person1);9NSLog (@"address of Person2:%p", Person2);Ten One //compares two objects for the same address A if([Person1 Isequal:person2]) { -NSLog (@"Two object addresses are the same"); -}Else{ theNSLog (@"Two object addresses are different"); - } - - //determine whether an object belongs to a class or to his parent class + if([Person1 Iskindofclass:[personclass]]){ -NSLog (@"Person1 belongs to the person class"); + } A at if([Person1 Iskindofclass:[nsobjectclass]]) { -NSLog (@"Person1 belongs to NSObject class"); - } - - - //Determines whether an object belongs to a class, but cannot determine its parent class in if([Person1 Ismemberofclass:[personclass]]){ -NSLog (@"Person1 belongs to the person class"); to}Else{ +NSLog (@"The genus Person1 is not of the person category"); - } the * if([Person1 Ismemberofclass:[nsobjectclass]]) { $NSLog (@"Person1 belongs to NSObject class");Panax Notoginseng}Else{ -NSLog (@"The genus Person1 is not of the NSObject class"); the } + A //determines whether a method is implemented in. m the if([Person1 respondstoselector: @selector (Actiontow)]) { +NSLog (@"Person1 implements the Actiontow"); -}Else{ $NSLog (@"Person1 did not implement the Actiontow"); $}
This article GitHub address Https://github.com/zhangkiwi/iOS_SN_NSObject
ios-oc-Basic-nsobject Common methods