我在我的应用程序添加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