Skip to content

Instantly share code, notes, and snippets.

@gholias
Created July 16, 2012 03:42
Show Gist options
  • Save gholias/3120333 to your computer and use it in GitHub Desktop.
Save gholias/3120333 to your computer and use it in GitHub Desktop.
-(void) parseResponseFromServer:(NSString*) output {
NSMutableDictionary* dict = [output objectFromJSONString];
NSMutableDictionary* theData;
int output_code = [[dict objectForKey:@"c"] intValue];
BOOL bStatus = [[dict objectForKey:@"s"] boolValue];
switch (output_code) {
case kConnect:
sUser = [dict objectForKey:@"u"];
debugLabel.text = [NSString stringWithFormat: @"Connected as %@", sUser];
btnLogin.hidden = false;
break;
case kLoginDone:
debugLabel.text = [NSString stringWithFormat: @"login status: %@", (bStatus)?@"True":@"False"];
btnListChannels.hidden = false;
break;
case kListChannelsDone:
theData = [dict objectForKey:@"d"];
NSMutableArray* tables = [theData objectForKey:@"tables"];
NSString* msg = @"Channels: ";
int c = 1;
for(NSDictionary* d in tables) {
msg =[NSString stringWithFormat: @"%@ \n%d - %@(%@)", msg, c++, [d objectForKey:@"name"], [d objectForKey:@"id"]];
}
debugLabel.text = msg;
break;
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment