【发布时间】:2011-03-31 12:21:39
【问题描述】:
我正在尝试正确进行内存管理,并且在下面的代码中,如果我包含最终的发布声明(用于 filePath 的声明),它会崩溃,我不明白为什么。我已经分配了,为什么不释放呢?
再往下,我将 cellAbout 返回到 TableView。
谁能解释一下?
UIImageView *imageView = (UIImageView *)[cellAbout viewWithTag:2];
NSString *filePath = [[NSString alloc] initWithString:self.gem.poiType];
filePath = [filePath stringByAppendingString:@".png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile: filePath];
imageView.image = image;
[image release];
[filePath release];
非常感谢,
克里斯。
【问题讨论】:
-
一般来说,要找到可能存在内存管理问题的地方,请尝试 xcode 中的“构建和分析”选项。它报告可疑的问题。
标签: iphone objective-c memory-management nsstring uiimage