0

UIImage를 내 서버에 업로드하는 앱을 작성하고 있습니다. 이것은 사진이 추가되는 것을 보면서 완벽하게 작동합니다. 이미지 데이터에 UIImageJPEGRepresentation을 사용하고 NSMutableRequest를 구성합니다.UIImageJPEGRepresentation을 사용하여 UIImage를 서버에 업로드

//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 출력 : 파일을 업로드하고이 코드를 작성 될 때 내가 UIAlertView를 표시 할

(URL, HTTP 메소드, 경계, 콘텐츠 형식 및 매개 변수를 설정) 2010-04를 -22 09 : 49 : 56.226 bbc_iwh_v1 [558 : 207] 반환 정보 : OK

문제는 내 if 문이 returnstring == @ "OK"를 말하지 않는다는 것입니다. 왜냐하면 AlertView를 얻지 못하기 때문입니다.

어떻게이 리턴 스트링 값을 검사해야합니까?

NSString * returnString; 

는 말 : 당신이 두 개의 포인터가 아니라 두 개의 문자열을 비교하려고하는

if (returnString == @"OK") 

답변

2

문제는 returnString 포인터 것입니다.

문자열을 비교하는 올바른 방법은 다음과 같습니다

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