2012年3月24日
摘要: 1:创建一个car对象头文件: @interface car : NSObject { } @end实现文件:@implementation car-(id) init{ if (self = [super init]) { NSLog(@"this is my name!and what's your name!"); } return(self);}//init@end实践得出的结果: 1若使用new创建的对象,则会自动调用方法init,代码如下: car *newCar = [car new]; 2如果使用alloc创建对象时,则需要手动调用方法:init。 阅读全文
posted @ 2012-03-24 11:40 wtq 阅读(189) 评论(0) 推荐(0) 编辑