Iphone 启用ARC时TWTweetComposeViewController内存泄漏
我有以下代码,导致泄漏,尽管在该文件上启用了ARC:Iphone 启用ARC时TWTweetComposeViewController内存泄漏,iphone,objective-c,Iphone,Objective C,我有以下代码,导致泄漏,尽管在该文件上启用了ARC: TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init]; [tweetViewController setInitialText:[self facebookAndTwitterStatus]]; tweetViewController.completionHandler = ^(TWTweetCompo
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
[tweetViewController setInitialText:[self facebookAndTwitterStatus]];
tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if(result == TWTweetComposeViewControllerResultDone) {
// the user finished composing a tweet
} else if(result == TWTweetComposeViewControllerResultCancelled) {
// the user cancelled composing a tweet
}
[self dismissViewControllerAnimated:YES completion:nil];
};
[self presentViewController:tweetViewController animated:YES completion:nil];
[self hideSettingsPopover];
显然,我没有发布版本,但如何才能消除此漏洞?在tweetViewController变量tweetViewController上使用u块 并在完成处理程序中将tweetViewController设置为nil
**__block** TweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
[tweetViewController setInitialText:[self facebookAndTwitterStatus]];
tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if(result == TWTweetComposeViewControllerResultDone) {
// the user finished composing a tweet
} else if(result == TWTweetComposeViewControllerResultCancelled) {
// the user cancelled composing a tweet
}
[self dismissViewControllerAnimated:YES completion:nil];
**tweetViewController = nil;**
};
__块复制您的tweetViewController,当您将其设置为nil时,它将被释放。
过渡到ARC发行说明中对此进行了解释。
不知道你的问题为什么被否决。我不知道为什么被否决。这是一个真正的问题,苹果的方法导致了泄漏。但是以前没有人问过这个问题?你怎么知道你有漏洞?如果你要让我们调试你的代码,而不亲自尝试解决这个问题,你至少可以告诉我们a)漏洞在哪里,b)你是如何发现的。代码不泄漏-对象会泄漏。那么,什么东西应该泄漏呢?用苹果公司的漏洞。他们确实在听。只需提供一个展示问题的示例项目。