使用UIImageJPEG表示将UIImage上载到服务器

使用UIImageJPEG表示将UIImage上载到服务器,uiimage,uploading,nsmutableurlrequest,uiimagejpegrepresentation,Uiimage,Uploading,Nsmutableurlrequest,Uiimagejpegrepresentation,我正在编写一个将UIImage上传到我的服务器的应用程序。这是完美的作品,因为我看到的图片被添加。我对图像数据使用UIImageJPEG表示,并配置NSMutableRequest。(设置url、http方法、边界、内容类型和参数) 我想在上载文件时显示UIAlertView,我编写了以下代码: //now lets make the connection to the web NSData *returnData = [NSURLConnection sendSynchronousReques

我正在编写一个将UIImage上传到我的服务器的应用程序。这是完美的作品,因为我看到的图片被添加。我对图像数据使用UIImageJPEG表示,并配置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]; 
返回字符串输出:2010-04-22 09:49:56.226 bbc_iwh_v1[558:207]返回信息:OK

问题是我的if语句没有说returnstring=@“OK”,因为我没有得到AlertView


如何检查此returnstring值

问题在于returnString是指针:

NSString * returnString;
当你说:

if ( returnString == @"OK" )
您正在尝试比较两个指针,而不是两个字符串

比较字符串的正确方法是:

if ([returnString isEqualToString:@"OK"])
{
    //do what you want
}