嗨,我有这个代码。
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;
}我已经在下面尝试过了。
if ([responseDict objectForKey:@"status = 1"]) {
Then do this
}但是它不起作用,我做错了什么,或者我能做什么?
发布于 2012-06-15 13:49:33
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才是关键,而不是你的全部..希望这能有所帮助..。
update:上面的代码行足够了,因为它返回1,它将继续,否则,如果条件为0,则条件为false,并转到else子句
https://stackoverflow.com/questions/11045215
复制相似问题