iOS中的LIExposeController存在内存管理问题

时间:2012-08-22 09:11:19

标签: ios memory-management

我正在使用“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

1 个答案:

答案 0 :(得分:0)

new开头的方法应该生成一个具有保留计数+1而不是自动释放/保留计数+0对象的对象。 ARC和静态分析器都遵循这些约定作为规则,您应该修复代码以满足它们或重命名方法以避免与约定发生冲突。