0

Hi I have this code.

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);

In the console this shows up.

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

Is there anyway I can make an if statement to show that if the value is 1 then do this and if it's not then do this. I have tried below.

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

But it didn't work, what am I doing wrong or what could I do?

1 Answers1

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

should be..

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

}

only status is the key not your entire thing.. hoping this helps..

update: The above lines are enough because of it reeturns 1 it will proceed else in case of 0 the condition is false and will go to the else clause

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115