Note that there are some explanatory texts on larger screens.

plurals
  1. POError parsing JSON data Objective C
    primarykey
    data
    text
    <p>I'm trying to sync data and after data gets synced I receive a message from the server. Now I'm suppose to display this message. But I'm getting error when parsing it. Below is my code..</p> <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:data{ NSLog(@"ConnectionDidReceiveData"); NSString *strdata=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding]; NSLog(@"Data as received =%@",strdata); if(strdata.length&gt;2) { SBJSON *jsonparser=[[[SBJSON alloc]init]autorelease]; NSDictionary *res= [jsonparser objectWithString:strdata]; NSLog(@"res = %@",res); NSArray *syncMessage = [res objectForKey:@"synchData"]; NSLog(@"syncMessage = %@",syncMessage); // NSDictionary *dict = [syncMessage objectAtIndex:2]; // NSLog(@"message = %@",[dict objectForKey:@"message"]); for (NSDictionary *result in syncMessage) { NSLog(@"result = %@",[result objectForKey:@"message"]); **&lt;---- Error Occurs Here.** // NSString *message = [result objectForKey:@"message"]; //NSLog(@"Message=%@",message); } } } </code></pre> <p>Error : </p> <pre> -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x93e9880 2013-11-26 10:43:07.723 M[608:11903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x93e9880' </pre> <p>JSON Response...</p> <pre><code>syncMessage = { code = 0; fromdate = "-0-"; message = "You have exceeded your leave count"; todate = "-0-"; } </code></pre> <p>Please help.</p> <p>Now the same code dosent work for this JSON, what could be wrong? My res variable is coming null.</p> <pre><code> {"synchData":{"message":"DCR Sync successful","code":1,"date":"2013-11-24"}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload