I added UIAlertController
in my app by creating a category on UIViewController
with the following method:
- (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];
}
At first, everything looks great but when I analyze leaks with Instruments, each time I call this method, some leaks appear:
Here is how the call of showAlertViewWithTitle:message:actions:
is done
[self showAlertViewWithTitle:nil message:@"Test message" actions:nil];
Any idea why I get all these leaks?
-- EDIT --
I tried the following in a sample project:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"message"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
and I get the same leaks. I'm really not sure what's going on...