1
- (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下給了他們@屬性。我無法弄清楚如何解決這個問題,我錯過了什麼!爲什麼這段代碼給我錯誤:「程序中意外的@」?
你肯定你」重新編譯爲目標c?該文件是否具有「.m」文件擴展名? – Dave 2013-05-05 15:57:27
是的,我使用File> New File> Objective-C Class創建了它。 – 2013-05-05 15:59:38