-1

我在尝试在我的 iPhone 应用程序中创建反馈表单并通过 php 邮件页面时遇到以下代码问题,我想知道下面的错误是否可能是原因。

以下代码显示了此问题“格式字符串未使用的数据参数” @"%@?email=%@&message=",特别是指此问题

NSString *email = [self.emailTxt text];
NSString *message = [self.messageTxt text];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?email=%@&message=", FeedbackURL, email, message]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
    NSString *title = (!error)? @"Message Sent" : @"Error";
    NSString *message = (!error)? @"Thank you for your Feedback, we hope it will help us to make this product even better." : @"There was an connection error. Please make sure you have internet connection and try again later.";
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];
    [alert show];

    NSLog(@"Error: %@", error.localizedDescription);
}];


if (email && (email.length > 0)) {
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:email forKey:UserEmailKey];
    [userDefaults synchronize];
}
4

2 回答 2

1

你忘了第三个%@

@"%@?email=%@&message="

第三个参数未填写,因为您缺少%@.

于 2013-04-06T14:32:41.820 回答
0

看起来 %@您的格式字符串中缺少 a :

@"%@?email=%@&message="

应该

@"%@?email=%@&message=%@"
于 2013-04-06T14:33:18.113 回答