我正在使用“LIExposeController”来创建新的UIViewControllers。这会带来一些我无法解决的内存警告。
- (UIViewController *)newViewControllerForExposeController:(LIExposeController *)exposeController {
UIViewController *viewcontroller = [[[MyViewController alloc] init] autorelease];
return viewcontroller; // warning here saying object with a + 0 retain count returned to caller where a + 1 (owning) retain count is expected
}
- (void)shouldAddViewControllerForExposeController:(LIExposeController *)exposeController {
[exposeController addNewViewController:[self newViewControllerForExposeController:exposeController]
animated:YES];
} // warning here saying potential leak of an object
LIExposeController *exposeController = [[[LIExposeController alloc] init] autorelease];
exposeController.viewControllers = [NSMutableArray arrayWithObjects:
[self newViewControllerForExposeController:exposeController],
nil]; // warning here saying potential leak of an object
答案 0 :(得分:0)
以new
开头的方法应该生成一个具有保留计数+1而不是自动释放/保留计数+0对象的对象。 ARC和静态分析器都遵循这些约定作为规则,您应该修复代码以满足它们或重命名方法以避免与约定发生冲突。