how to open MFmessageComposeviewcontroller
on any view controller (topviewcontroller) from NSObject
class method excute in background.
This is my code which popup massage controller without error
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = @"Check out FundooSpace for mobile. Download it now from www.lsaknlansc.cas.kasjla/FundooSpace/d";
controller.recipients=(NSArray *)passa;
passa=nil;
AppDelegate *appDelegateObject1 = (AppDelegate *)[[UIApplication sharedApplication] delegate];
controller.messageComposeDelegate=self;
[appDelegateObject1.navigationCntr.topViewController performSelectorOnMainThread:@selector(presentModalViewController:animated:) withObject:controller waitUntilDone:NO];
}
But 1 after send or cancel button clicked then it get crash.
2. The delegate
method is not called (how to set delegate to message controller)
I think the NSObject running in background is released. It is also the delegate for the Compose View Controller, so the fatal error: EXC BAD ACCESS. The property messageComposeDelegate doesn't retain the object. You are using ARC, aren't you?
Try to retain the object assigning it to any strong var until the compose view controller ends.