I have a problem with SLComposeViewController in IOS 8. I want to show Facebook sharing window and after it's done - show Twitter sharing window. That's why I need to use completion blocks and to avoid retain cycles I have to use __weak SLComposeViewController, but when I call
[viewController presentViewController:facebookSLController animated:YES completion:Nil];
my facebookSLController
is nil. It's because of __weak
. But why it didn't crash in IOS 7?
And how can I solve this problem? Here is part of code:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
__weak SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:text];
//When facebook sharing end - we start twitter sharing
[controller setCompletionHandler:^(SLComposeViewControllerResult result) {
[controller dismissViewControllerAnimated:YES completion:nil];
[self shareTwitterImage:image withText:strGetApp fromViewController:viewController];
}];
[controller addImage:image];
[viewController presentViewController:controller animated:YES completion:Nil];
}