摘要: 本节目录retainassigncopyretain先建一个student类,和一个Book类,学生拥有有一本书Book.m#import "Book.h"@implementation Book-(void)dealloc{ NSLog(@"Book 被销毁"); [super dealloc];}@endStudent.h,nonatomic先不理,后面来讲#import #import "Book.h"@interface Student : NSObject@property(nonatomic,retain)Book *bo 阅读全文
posted @ 2014-03-17 18:06 Vincent_Guo 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 本节内容dealloc方法retain方法一、dealloc方法当一个对象被销毁释放时,会调用dealloc方法在Staff类中重写下dealloc方法,记住,最后得调用父亲的dealloc方法,因为父类可能还有些对象有释放#import "Staff.h"@implementation Staff-(void)dealloc{ NSLog(@"Staff 被销毁"); [super dealloc];}@end#import #import "Staff.h"int main(int argc, const char * argv[ 阅读全文
posted @ 2014-03-17 16:46 Vincent_Guo 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 本节目录@property@synthesize@property前面写一个age属性,又要写set/get方法,比较麻烦,@property就是简化操作的Staff.h#import @interface Staff : NSObject@property int age;@end上面的代码等效于在头文件声明了age的set/和get方法-(void)setAge:(int)newAge;-(int)age;@synthesize在头文件声明了age的set/get方法后,在点.m文件中要实现get/set方法,@synthesize就是自动来为你做这事的。Staff.m#import &q 阅读全文
posted @ 2014-03-17 16:11 Vincent_Guo 阅读(189) 评论(0) 推荐(0) 编辑