#import <foundation/foundation.h>/* Object Method 1> minus-the beginning 2> can only be called by the object to invoke the member variable (instance variable) of the current object in the 3> object method 1> Plus + begins 2& Gt Can only be called by the class (name) in the 3> class method can not access the benefits of the member variable (instance variable) class method and the use of the application 1> not depend on the object, the execution efficiency is high 2> can use class method, try to use class method 3> occasion: When the method inside does not need to use the member variable, You can change the class method to allow the same name as the class method and the object method */@interface person:nsobject{int age;} Class methods are preceded by + (void) printclassname;-(void) test;+ (void) test; @end @implementation person+ (void) printclassname{//Erro R:instance variable ' age ' accessed in class method//Instance variable "The class cannot access the//nslog (@" This class is called person-%d ") -(void) test{NSLog (@ "111-%d", age); [Person test];} + (void) test{//will cause a dead loop//[person test]; NSLog (@ "333"); Will cause a dead loop///[person test];} @endint Main () {//[person printclassname]; [Person Test]; Person *p = [person new]; [P test]; /*-[person Printclassname]: Unrecognized selector sent to instance 0x7fa520c0b370////The system will assume that the Printclassna is now called Me is an object method//[p Printclassname]; return 0;}
05-Class--+-number use