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:
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 ...
Tôi không thấy bất kỳ rò rỉ nào bằng cách sử dụng xcode 6. – gabbler
Còn Xcode 6.0.1 thì sao? – MartinMoizard
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