我刚刚分析了我的 iPhone 项目,对 XCode(4) 给我的结果感到非常困惑。例如,在我的一个视图控制器中,我有以下代码:
@property (nonatomic, retain) NSArray* menuItems;
@property (nonatomic, retain) NSArray* menuItemsOptions;
- (void)viewDidLoad
{
[super viewDidLoad];
self.menuItems = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"Foo", nil),
NSLocalizedString(@"Bar", nil),
nil];
[self.menuItems release];
self.menuItemsOptions = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"More foo", nil),
NSLocalizedString(@"more bar", nil),
nil];
[self.menuItemsOptions release];
...
}
menuItems
以及menuItemsOptions
带有retain
选项的属性。如果我按分析,XCode 将显示该行的错误[self.menuItems release];
:
http://i54.tinypic.com/2rqkfaf.png
更让我困惑的是,XCode不会显示该行的错误[self.menuItemsOptions release];
另一种方法中的类似情况:
http://i55.tinypic.com/10hof9c.png
theSelectedBegin
并且theSelectedEnd
再次是具有保留选项的属性。
我发布这个的原因是我的应用程序实际上会在第三方库中以非常神秘/不可理解的回溯崩溃,除非我copy
在最后一张图片上添加看到但不添加release
. 添加release
或省略copy
将使应用程序再次崩溃,这就是我决定运行分析器的原因。
我究竟做错了什么?