I am using ASIHTTPRequest to get JSON response from server. And I want to convert this response to NSArray. My code:
NSURL *url = [NSURL URLWithString:@"http://chirkov.net.ua/iosnettest/request.php?act=showdata&query=2;0;3;0;ASC"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSData *responseData = [[NSMutableData alloc] initWithData:[request responseData]];
NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:responseData];
NSLog(@"array = %@",array);
}
But got exception Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0xffffffef, 0xffffffbb, 0xffffffbf, 0x5b, 0x7b, 0x22, 0x69, 0x64
.
How can I solve my problem?
You getting JSON data so you have to convert that data using NSJSONSerialization. Have a look at class reference.
Also check this Working with JSON