@implementation Person
+ (void)test
{
NSLog(@"+test!");
}
+ (void)run
{
NSLog(@"人在走");
// self指代的是当前的类
NSLog(@"self = %p", self);
// 使用类调用类方法
[self test];
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
Person *p = [Person new];
NSLog(@"p = %p", p);
// [p class]返回的实质就是当前类(类对象)
NSLog(@"Person = %p", [p class]);
// 通过Person调用其类方法
[Person run];
}
return 0;
}