I was trying to parse response data from web server. I am using Xcode 4.2.
NSLog(@"Establishing connection...");
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"example.com/test.php"]]; [request setHTTPMethod:@"GET"];
accept = @"Kokokoko";
NSLog(@"Adding value for HTTP Header");
[request addValue:accept forHTTPHeaderField: @"Accept"];
NSLog(@"Sending request...");
//send request & get response
returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSLog(@"Request sent");
Then I want to use returnData to parse JSON response. It should be
["Test", "42", "OK"]
So I was trying to use NSDictionary and JSONValue and other tricks but I was not succeed. Maybe there is a simple solution for this problem?
If you expect your server to return a string like that:
Then the JSONValue of it would be NSArray (not NSDictionary). Try this: