person.h
#import <Foundation/Foundation.h>
@interface Person : NSObject
@property int age;
@property id obj;
@end
person.m
#import "Person.h"
@implementation Person
@end
main函數
int main(int argc, const char * argv[])
{
@autoreleasepool {
Person *p = [Person new];
//[p fsdfdsfd];
NSObject *o = [Person new];
// id == NSObject *
// 萬能指針,能指向\操作任何OC對象
id d = [Person new];
[d setAge:10];
[d setObj:@"321423432"];
NSLog(@"%d", [d age]);
}
return 0;
}