UIActivityViewController - 无法理解这个内存泄漏

时间:2013-02-20 19:28:43

标签: iphone ios objective-c memory-leaks uiactivityviewcontroller

有人可以告诉我为什么以下代码在仪器中泄漏了吗?

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityController.excludedActivityTypes = [NSArray arrayWithObjects:@"a",@"b", nil];


[self presentViewController:activityController animated:YES completion:nil];
[activityController release];    

仪器显示行上的泄漏:

activityController.excludedActivityTypes = [NSArray arrayWithObjects:@"a",@"b", nil];

1 个答案:

答案 0 :(得分:0)

以下应该做的技巧(__block和完成)

__block UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityController.excludedActivityTypes = [NSArray arrayWithObjects:@"a",@"b", nil];

[self presentViewController:activityController animated:YES completion:^{ activityController.excludedActivityTypes=nil; activityController=nil;}];
[activityController release];

另见SO