I am running into an error using SBJSON parser on a response string returned from a PHP webservice:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSError *error;
SBJSON *json = [SBJSON new];
NSArray *returnedFromWeb = [json objectWithString:responseString error:&error];
[articles_parsed removeAllObjects];
for (int i = 0; i < [returnedFromWeb count]; i++)
{
NSDictionary *dictColumns = [returnedFromWeb objectAtIndex:i];
[self parseArticlesObject:dictColumns];
dictColumns = nil;
}
I receive an unrecognized selector sent to instance error on the objectAtIndex call above. When I check the values contained in my array (returnedFromWeb), it shows that there are 17 objects. However, inspecting each object shows the following error:
(<invalid>) [0] = <error: expected ']' error: 1 errors parsing expression >
I have posted below the data returned from the SBJSON parser for the object at index [0] below:
{
0 = {
author = "CCJ Staff";
category1 = Products;
excerpt = "Toyo";
modified = "2014-03-25 08:33:57";
"short_link" = "http://www.example.com/?p=95326";
thumbnail = "http://www.example.com/files/2014/03/ Tire.jpg";
"thumbnail_243x243" = "http://www.example.com/ihz.php?src=/blogs.dir/10/files/2014/03/ Tire.jpg&w=243&h=243&q=100&zc=1";
title = "medium-duty";
};
And here is the string that is being parsed by SBJSON (shortened to contain only the first object, the comma at the end is where the next object would begin):
{"numberposts":240,"tax_query":[{"taxonomy":"topic","terms":[75,43550,14394,16564,1795,43,22,12950],"field":"term_id","orderby":"date","order":"DESC"}],"0":{"title":"medium-duty","category1":"Products",
excerpt":"Toyo","modified":"2014-03-25
08:33:57","author":"Staff","thumbnail":"http://www.ccjdigital.com/files/2014/03/Tire.jpg","short_link":"http://www.ccjdigital.com/?p=95326"},
Any help is appreciated! I am fairly new to iOS and SBJSON, and have not been able to figure out why my array is invalid.