BOOL - 对象的潜在泄漏

时间:2011-12-10 00:16:28

标签: objective-c

我正在获得对象分配消息的潜在泄漏。我该如何解除它?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

  extern BOOL _mainWebViewLoaded;  // **-> Potential leak of an object allocated

    Nimble *nimble = [[Nimble alloc] initWithRootPage:@"main.html" window:self.window serial:@""];
    [nimble release]; 
    [self.window makeKeyAndVisible];
    while (!_mainWebViewLoaded) {
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
    }
    return YES ;



}

1 个答案:

答案 0 :(得分:3)

它是自我暴露,而不是BOOL。自动发布你的self.window:

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

很好地解释了推理here