0

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

1 回答 1

0

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

于 2012-08-22T09:15:09.590 回答