OC语言—self用法 /* self指向当前对象
1、[self 方法变量]访问当前对象内部的成员变量
2、[self 方法名]
*/
#include <Foundation/Foundation.h>
@interface Dog : NSObeject
{
int _age;
}
- (void)bark;
- (int)run;
@end
@implementation Person
- (void)bark
{
NSLog(@"旺旺");
}
- (int)run
{
[self bark];
//NSLog(@"旺旺");
NSLog(@"跑了");
}
@end
int main()
{
Dog *d=[Dog new];
[d run];
return 0;
}
|
|