我在我的應用程序添加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];
}
起初,一切看起來不錯,但是當我分析泄漏與儀器,每次我調用此方法一些泄漏出現:
這裏是如何的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];
,我也得到相同的泄漏。我真的不知道是怎麼回事......
我沒有看到任何泄漏使用Xcode 6. – gabbler 2014-10-13 14:49:15
Xcode 6.0.1呢? – MartinMoizard 2014-10-13 15:17:54
我正在使用6.0.1,你是如何發現泄漏的?我沒有看到儀器的泄漏面板 – gabbler 2014-10-13 15:30:50