开发者

Releasing UIViewControllers and LLVM static analysis

When compiling my app with LLVM, just about the only errors I get are:

Potential leak of an object allocated on line xxx

This is in response to code creating and pushing a new UIViewController onto a UINavigationController:

FooViewController *vc = [[FooViewController alloc] initWithNibName:@"FooViewController" bundle:nil];
vc.title = @"FooFoo";
[self.nav开发者_如何学GoigationController pushViewController:vc animated:YES];

So I guess it's suggesting I put this after the last line:

[vc release];

But whenever I do that, it causes errors EXC_BAD_ACCESS. I don't see why I would release it anyway, since I want it to remain in memory, don't I? How would I get around this to make the LLVM compiler happy?


Your navigation controller will retain the view controller, so there's no need for you to do so. (i.e.: The [vc release]; line should be in there.)

As such, I'm guessing the problem with the EXC_BAD_ACCESS lies elsewhere, but it's hard to tell without some additional surrounding information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜