OC 类内部class方法和实例方法相互调用
2017-11-10 本文已影响0人
PengboGai
from:http://blog.csdn.net/chenyufeng1991/article/details/47035847
例如 class里面有两个方法 show 和show2,分别是实例方法和class方法(静态方法) 实例方法可以调class方法,class方法不能直接调实例方法
-(void)show;
+(void)show2;
-(void)show{
NSLog(@"我是一个对象方法,我被调用了!");
[Peopleshow2];//调用类方法
}
+(void)show2{
NSLog(@"我是一个类方法,我被调用了!");
// [[People alloc] show];
}
People*people = [[Peoplealloc]init];//注意没有在main.m中直接调用
[people show ];