2012-06-15 3 views
0

안녕하세요.이 코드가 있습니다.NSJSONSerialization 문제

NSString *infoString = [NSString stringWithFormat:@"http://link.com/post.php?name=%@&street=%@&city=%@&state=%@&zip=%@&lat=%@&lon=%@", name, street, city, state, zip, str1, str2]; 
     NSURL *infoUrl = [NSURL URLWithString:infoString]; 
     NSData *infoData = [NSData dataWithContentsOfURL:infoUrl]; 

     NSError *error; 
     responseDict = [NSJSONSerialization JSONObjectWithData:infoData options:0 error:&error]; 
     NSString *responseString = [responseDict copy]; 
     NSLog(@"responseDict: %@", responseString); 

콘솔에 표시됩니다.

2012-06-14 22:37:04.022 PartyApp[20221:fb03] responseDict: { 
    status = 1; 
} 

어쨌든 거기에 내가 할 수있는 문이 값이 1이면이 작업을 수행 할 것을 보여 경우 그 다음이 작업을 수행 있지 않은 경우입니다. 나는 아래에서 시도했다.

if ([responseDict objectForKey:@"status = 1"]) { 
      Then do this 
     } 

하지만 작동하지 않았습니다. 무엇이 잘못 되었나요? 아니면 무엇을 할 수 있습니까? 위의 라인 :

답변

0
if ([responseDict objectForKey:@"status = 1"]) { 
      Then do this 
     } 

해야한다 ..

if ([responseDict objectForKey:@"status"]) { 
      //this will be done in case of 1 
     }else{ 
//this will be done in case of 0 

}

status가 아닌 전체 일이 .. 희망이 도움이 키 ..

갱신입니다 그것 때문에 1이면 0으로 진행하고, 조건이 거짓이면 else 클로스로갑니다. e

+0

앱이 0 또는 1을 반환했는지 어떻게 알 수 있습니까? –

+0

@DewanPayroda는 내 업데이트를 살펴 봅니다. –

+0

알았습니다! 고마워. –