这是我的问题,我应该手动将我的强属性设置为 nil 以释放它吗?
在 mytest.h 文件中
@property(nonatomic,strong) IBOutlet UIView *myView;
@property(nonatomic,weak) IBOutlet UILabel *myLabel;
@property(nonatomic,strong) MyObject *myObject;
@property(nonatomic,strong) NSArray *theArray;
1)在iOS5中,哪一个是正确的?功能A?还是功能 B?或功能C?
//function A
-(void)viewDidUnLoad{
[super viewDidUnLoad];
self.myView=nil; //strong property
//I do not need to self.myLabel=nil, because it is weak property
self.myObject=nil;//strong property
self.theArray=nil;//strong property
}
//function B
-(void)viewDidUnLoad{
[super viewDidUnLoad];
self.myView=nil; //strong property
//I do not need to self.myLabel=nil, because it is weak property
//self.myObject=nil;//strong property ,but ARC will release it in dealloc
//self.theArray=nil;//strong property ,but ARC will release it in dealloc
}
//function C
-(void)viewDidUnLoad{
[super viewDidUnLoad];
//do nothing here
//ARC will release it in dealloc
}
2) 在 iOS6 中 viewDidUnLoad 已被弃用,并且文档告诉我不要关心 IBOUlet 属性。那么在 ios6 下面哪个是正确的。
//function A
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
//self.myView=nil; //strong property ,but ios6 document tells me not to care IBOutlet
//self.myObject=nil;//strong property ,but ARC will release it in dealloc
//self.theArray=nil;//strong property ,but ARC will release it in dealloc
}
//function B
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
//self.myView=nil; //strong property ,but ios6 document tells me not to care IBOutlet
self.myObject=nil;//strong property
self.theArray=nil;//strong property
}
有谁知道详情,希望得到您的答复
顺便说一句,你认为ARC会扫描我的文件,并在编译器添加发布后自动为我添加“发布”(实际上我们在ARC中看不到任何发布)
-(void)dealloc{
[self.myView release];
[self.myObject release];
[self.theArray release];
[super dealloc];
}