为什么这段代码会给我错误:“程序中意外的@”?

时间:2013-05-05 15:53:29

标签: objective-c

- (IBAction) createAccount: (id) sender {

NSString *post =[NSString stringWithFormat:@”name=%@&password=%@&email=%@”,nameField.text, passwordField.text, emailField.text];

NSString *hostStr = @”domain.tk/in-app/account/create-account.php?”;
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];







if([serverOutput isEqualToString:@”Yes”]){


    UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@”Congrats” message:@”Your account has bee succesfully created. “
                                                          delegate:self cancelButtonTitle:@”OK” otherButtonTitles:nil, nil];

    [alertsuccess show];
    [alertsuccess release];


} else {
    UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@”Error” message:@”We are sorry, but an error has been encountered, please try agian later.”
                                                          delegate:self cancelButtonTitle:@”OK” otherButtonTitles:nil, nil];
    [alertsuccess show];
    [alertsuccess release];

}

}

我在几乎所有有@的行上都收到错误,我该怎么办呢?我(想想我)已经合成了我的所有字段并在@interface中完成了IBOutlet,并在@interface下面给了它们@ property。我无法弄清楚如何解决这个问题,我错过了什么!

1 个答案:

答案 0 :(得分:6)

在代码中使用常规引号替换印刷引号"应该会有所帮助: - )

(如果您复制/粘贴代码,例如来自PDF文档,则会发生这种情况。)