根据Apple Doc:
" 实例方法是一种方法,其执行范围限定为类的特定实例。换句话说,在调用实例方法之前,必须先创建该类的实例。实例方法是最常用的方法类型。
类方法是一种方法,其执行范围限定在方法的类中。它不需要对象的实例作为消息的接收者。"
*那真的是"自我" ?为什么它可以接收类方法和实例方法?所以" 在调用实例方法之前,必须先创建类的实例"是错的 ?示例:
{ ...
[self method1];
//I'm doesn't create any instance of class//
[self method2];
}
-(void)method1 {
NSLog(@"this is a instance method");
}
+(void)method2 {
NSLog(@"this is a class method");
}