2014-10-09 20 views
18

tôi thêm UIAlertController trong ứng dụng của tôi bằng cách tạo ra một thể loại trên UIViewController với phương thức sau:Rò rỉ với 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]; 
} 

Lúc đầu, mọi thứ sẽ rất tốt nhưng khi tôi phân tích rò rỉ với Instruments, mỗi khi tôi gọi phương pháp này , một số rò rỉ xuất hiện:

enter image description here

Sau đây là cách gọi của showAlertViewWithTitle:message:actions: được thực hiện

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

Bất kỳ ý tưởng nào tại sao tôi nhận được tất cả các rò rỉ này?

- EDIT -

Tôi đã thử các sau đây trong một dự án mẫu:

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

và tôi nhận được rò rỉ tương tự. Tôi thực sự không chắc chắn điều gì đang xảy ra ...

+0

Tôi không thấy bất kỳ rò rỉ nào bằng cách sử dụng xcode 6. – gabbler

+0

Còn Xcode 6.0.1 thì sao? – MartinMoizard

+0

Tôi đang sử dụng 6.0.1, làm thế nào bạn tìm thấy sự rò rỉ? Tôi không thấy bảng điều khiển rò rỉ ở các công cụ – gabbler

Trả lời

-2

Rò rỉ có vẻ như đã được khắc phục với iOS 8.2 và Xcode 6.2

+3

Không. Rò rỉ trong ** iOS 8.3 **, ** Xcode 6.3 **. – SwiftArchitect

+0

Sẽ không bị rò rỉ trên thiết bị thực tế. – OhadM