OC语言—Id万能指针
/* id 是万能指针,能指向\操作任何OC对象
*/
#include <Foundation/Foundation.h>
@interface Person: NSObeject
@property int age;
@end
@implementation Person
@synthesize age = _age;
@end
int main()
{
@autoreleasepool{
Person *p=[Person new];
//NSObeject *0=[Person new];
id d=[Person new];
[d setAge:10];
NSLog(@"%d",[d age]);
}
return 0;
}
|
|