为什么在dealloc 一般用 [x release]; 而不用self.x = nil; 而在viewDidUnload中 一般用self.x = nil; 而不用[x release]; self.x = nil; 等价于先release再置nil的,这是属性的用法 delloc中不利用self.x = nil是基于以下2方面考虑 1。调用delloc函数时候,KVO已经不再利用了(你要知道self.x会 触发kvo)。 2。x的set函数有可能被子类override 在viewDidUnload中(内存不够的时候,view在后台的话,会触发此函数) 直接用self.x = nil 即可,如果release了,因为置了nil,所以在delloc中 [nil release]也是没问题的。 参考材料:http://stackoverflow.com/questio ... -with-viewdidunload |