iphone - How to fix an NSString Expected expression error in a switch statement? -
this question has answer here:
i'm getting "expected expression" error in switch statement on first line of code below in nsstring: nsstring *emailtitle = @"some text";
break; case 4: // mail // email subject nsstring *emailtitle = @"some text"; // email content nsstring *messagebody = @"http://www.example.com/"; // address nsarray *torecipents = [nsarray arraywithobject:@""]; mfmailcomposeviewcontroller *mc = [[mfmailcomposeviewcontroller alloc] init]; mc.mailcomposedelegate = self; [mc setsubject:emailtitle]; [mc setmessagebody:messagebody ishtml:no]; [mc settorecipients:torecipents]; // present mail view controller on screen [self presentviewcontroller:mc animated:yes completion:null]; break; case 5:
without piece of email code switch statement works fine.
thanks help
you can't declare variable in case statement, because scope ambiguous...
change below, scope specified brackets {}
case 4: { // mail // email subject nsstring *emailtitle = @"some text"; // email content nsstring *messagebody = @"http://www.example.com/"; // address nsarray *torecipents = [nsarray arraywithobject:@""]; mfmailcomposeviewcontroller *mc = [[mfmailcomposeviewcontroller alloc] init]; mc.mailcomposedelegate = self; [mc setsubject:emailtitle]; [mc setmessagebody:messagebody ishtml:no]; [mc settorecipients:torecipents]; // present mail view controller on screen [self presentviewcontroller:mc animated:yes completion:null]; } break; case 5:
Comments
Post a Comment