0

the following code:

-(void)sendSMS
{
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    if ([MFMessageComposeViewController canSendText])
    { 
        self.msgController = [[MFMessageComposeViewController alloc]init];
        self.msgController.messageComposeDelegate = self;
        self.msgController.body = [standardUserDefaults objectForKey:@"geoAlarmDistressFlareMsgText"];
        self.msgController.recipients = [standardUserDefaults objectForKey:@"geoAlarmDistressFlareTelNumbers"];
        [self presentModalViewController:self.msgController animated:YES];
    }
}

...causes the app to crash when run on my iphone at the [[MFMessageComposeViewController alloc]init]; line with the following error:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString count]: unrecognized selector sent to instance

I don't understand why - the msgController is declared (and synthesized) as a MFMessageComposeViewController, and i have declared the delegate and delegate method. Any ideas? No other questions on here seem to be asking the same question...

HillInHarwich
  • 441
  • 6
  • 25
  • sorry.. that should be that I have implemented the delegate method (didFinishWithResult) – HillInHarwich Jul 13 '12 at 09:15
  • I just the code above in another view controller class and it worked ok... There must be something peculiar to what I am doing that is causing this error. The implementation for this part of the code is identical in both though! Very strange... – HillInHarwich Jul 13 '12 at 13:05

0 Answers0