【发布时间】:2013-06-11 10:16:45
【问题描述】:
我有一个愚蠢的问题,在我的代码中:
在.h中
@property (nonatomic, retain) UIImage *currentImage;
英寸米
@syntesyze currentImage;
然后在我的课堂上我使用“self.currentImage”...
在 dealloc 中我尝试做:
[self.currentImage release] or self.currentImage = nil
但是我的应用程序崩溃了,问题是“消息发送到已释放的实例”,为什么?我在 .h 中有一个保留,有什么问题?
【问题讨论】:
-
请仅使用 [currentImage release] 尝试;
-
@syntesyze是这里的错字还是在您的代码中? -
我们在 viewDidUnload 方法中执行 self.currentImage = nil 。虽然你的代码看起来不错。我会建议你启用 NSZombies 来解决与内存相关的问题。它会告诉你对象在哪里被释放
标签: ios properties retain