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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -