2014-10-09 37 views
18

我在我的應用程序添加UIAlertController通過創建一個類別上UIViewController以下方法:泄漏與UIAlertController

- (void)showAlertViewWithTitle:(NSString *)title 
         message:(NSString *)message 
         actions:(NSArray *)alertActions 
{ 
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title ? : @"" message:message preferredStyle:UIAlertControllerStyleAlert]; 

    if (alertActions.count) { 
     for (UIAlertAction *action in alertActions) { 
     [alertController addAction:action]; 
     } 
    } else { 
     UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; 
     [alertController addAction:action]; 
    } 

    [self presentViewController:alertController animated:YES completion:nil]; 
} 

起初,一切看起來不錯,但是當我分析泄漏與儀器,每次我調用此方法一些泄漏出現:

enter image description here

這裏是如何的showAlertViewWithTitle:message:actions:的調用完成

[self showAlertViewWithTitle:nil message:@"Test message" actions:nil]; 

任何想法,爲什麼我會得到所有這些泄漏?

- 編輯 -

我想在一個示例項目如下:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"message" 
                delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
[alertView show]; 

,我也得到相同的泄漏。我真的不知道是怎麼回事......

+0

我沒有看到任何泄漏使用Xcode 6. – gabbler 2014-10-13 14:49:15

+0

Xcode 6.0.1呢? – MartinMoizard 2014-10-13 15:17:54

+0

我正在使用6.0.1,你是如何發現泄漏的?我沒有看到儀器的泄漏面板 – gabbler 2014-10-13 15:30:50

回答

-2

泄漏似乎是固定的與iOS 8.2和6.2的Xcode

+3

沒有。泄漏在** iOS 8.3 **,** Xcode 6.3 **中。 – SwiftArchitect 2015-05-18 20:43:13

+0

不會在實際設備上泄漏。 – OhadM 2015-08-11 11:43:22