0

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

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];
4

1 回答 1

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

于 2013-02-20T22:18:25.137 回答