我正在编写一个将 UIImage 上传到我的服务器的应用程序。这很完美,因为我看到正在添加的图片。我将 UIImageJPEGRepresentation 用于图像数据并配置 NSMutableRequest。(设置url、http方法、边界、内容类型和参数)
我想在上传文件时显示一个 UIAlertView 我写了这段代码:
//now lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"return info: %@", returnString);
if (returnString == @"OK") {
NSLog(@"you are snapped!");
// Show message image successfully saved
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"You are snapped!" message:@"BBC snapped your picture and will send it to your email adress!" delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil];
[alert show];
[alert release];
}
[returnString release];
returnString 输出:2010-04-22 09:49:56.226 bbc_iwh_v1[558:207] 返回信息:OK
问题是我的 if 语句没有说 returnstring == @"OK" 因为我没有得到 AlertView。
我应该如何检查这个返回字符串值?