Gre*_*reg 1 iphone objective-c dealloc viewdidload
我会感兴趣的是任何能够在"viewDidUnload"中提供关于下面的Apple推荐(在核心数据教程中找到)的更多信息的人.例如:
码:
// The implementation of viewDidUnload should relinquish ownership
// of anything created in viewDidLoad that can be recreated.
- (void)viewDidUnload {
self.eventsArray = nil;
self.locationManager = nil;
self.addButton = nil;
}
- (void)dealloc {
[managedObjectContext release];
[eventsArray release];
[locationManager release];
[addButton release];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
将属性设置为nil也将释放它们(假设setter方法释放旧值,因为它应该这样做).
此外,将属性设置为nil意味着之后可能最终被发送给它们的任何消息都将被吞并并被nil忽略.在它们被简单释放的情况下,对象可能会被释放并在内存中被覆盖,但它们仍然可以向它们发送消息(现在被发送到内存中的任何覆盖它们),可能导致崩溃,异常或其他意外行为.
| 归档时间: |
|
| 查看次数: |
188 次 |
| 最近记录: |