#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
//当前对象p 先吃东西,然后再走(吃和走是同一个对象)
Person *p = [Person new];
NSLog(@"%p",p);
//[p run];
[p eat:@"油条+鸡蛋"];
}
return 0;
}
#import <Foundation/Foundation.h>
@interface Person : NSObject
-(void)run;
-(void)eat:(NSString*) foodName;
@end
#import "Person.h"
@implementation Person
-(void)run{
NSLog(@"人在走!");
}
-(void)eat:(NSString*) foodName{
NSLog(@"人在吃%@",foodName);
// Person *p1 = [Person new];
// [p1 run];
NSLog(@"%p",self);
/lf 在对象方法中使用
/lf 指代的是调用当前对象方法的那个对象
//[p eat:@""]; self 指代的就是p
[self run];
}
@end
|
|