これが私の質問です。強力なプロパティを手動で 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 プロパティを気にしないようにと書かれています。
//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];
}