I have the following code, which is causing a leak, despite ARC being enabled on that file:
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];
Obviously i don’t have a release, but how can i get rid of this leak?
Use __block on your TwTweetViewController variable tweetViewController
and set tweetViewController to nil in your completion handler.
The __block copies your tweetViewController and it’s released when you set it to nil.
This is explained in Transitioning to ARC release notes.
http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html
Not sure why your question was down voted.