其他三个if语句

时间:2013-02-23 23:07:43

标签: iphone objective-c compiler-errors

您好我正在尝试使用4个按钮,按下时每个按钮都有不同的警报。我遇到了一个问题,我有3个按钮,我决定添加一个“评价我的应用程序”按钮,但现在它不工作,请帮助我。 (顺便说一下,错误是 Expexted Exspression )(组织(在应用程序中已修复),电子邮件 - 应用程序中的真实电子邮件,

#define TAG_Band 1
#define TAG_DEV 2
#define TAG_EDEV 3
#define TAG_RATE 4

@interface Org.ContactInfo () <MFMailComposeViewControllerDelegate>

@end

@implementation Org.ContactInfo:UIViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"Contacts";

    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(IBAction)ContactBand:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact the Band" message:@"Contact the Org. or go to their website!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Visit the Org. Website",@"E-Mail The Org. President", @"E-Mail The Org. Treasurer",  nil];
    alert.tag = TAG_Band;
    [alert show];
}
-(IBAction)ContactDev:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact Me" message:@"Contact Me on Features you would like me to consider! I will do my Best to look at all of the Suggestions!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Visit My Website",@"E-Mail Me!",  nil];
    alert.tag = TAG_DEV;
    [alert show];
}
-(IBAction)RateMyApp:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate My App" message:@"When Your Reviewing my App, Please remember that this app was at no cost to the Mighty Mustang Band." delegate:self cancelButtonTitle:@"Not Right Now" otherButtonTitles:@"Rate My App!!",  nil];
    alert.tag = TAG_RATE;
    [alert show];


}
-(IBAction)AppInfo:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Version 1.0" message:@"More Updates Coming Soon. Please Feel Free to E-Mail me on features that you would like me to consider" delegate:self cancelButtonTitle:@"Not Right Now" otherButtonTitles:@"Email-Me",  nil];
    alert.tag = TAG_EDEV;
    [alert show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == TAG_Band){


        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://URL.org"]];

        }
        else if (buttonIndex==2){
            //Subject
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"Org. President";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Person@Org.org"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
        else if (buttonIndex==3){
            //Subject
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"Org. Treasurer, ";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Person@Org.org"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_DEV){
        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://stepheniosdeveloper.wordpress.com"]];

        }
        else if (buttonIndex==2){
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Email@gmail.com"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_EDEV);{
        if (buttonIndex==1){
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Email@gmail.com"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_RATE);{         //Expected Expression
        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/Org/id607257427?ls=1&mt=8"]];
        }
    }
}

它起作用之前我添加了最后一个(TAG_RATE)但现在我不明白为什么它不再起作用了。请帮助。

1 个答案:

答案 0 :(得分:3)

您的代码中存在拼写错误:在最后两个;条件之后,您有额外的else if

    else if (alertView.tag == TAG_EDEV)/*;*/{  // extra `;`
            //...
    }
    else if (alertView.tag == TAG_RATE)/*;*/{   // extra `;`       //Expected Expression
            // ...
    }