I'm trying to parse the following JSON information that comes out of my PHP file:
{
"netSales":0,
"voidSales":0,
"discountSales":0,
"guestCount":null,
"servedCount":null,
"loggedIn":9
}
My string is set something like this:
NSURL * url = [NSURL URLWithString:salesStr];
NSData * data = [NSData dataWithContentsOfURL:url];
json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@"response type is %@",[json class]);
//Set up our cities array
arrayOfStore = [[NSMutableArray alloc]init];
for (int i = 0; i < json.count; i++)
{
NSString * netSales = json[i][@"netSales"];
NSString * voids = json[i][@"voidSales"];
NSString * discounts = json[i][@"discountSales"];
NSString * guestCount = json[i][@"guestCount"];
NSString * peopleServed = json[i][@"servedCount"];
NSString * employeesClock = json[i][@"loggedIn"];
Store * myStore = [[Store alloc]initWithNetSales: (NSString *) netSales andVoids: (NSString *) voids andDiscounts: (NSString *) discounts andGuestCount: (NSString *) guestCount andPeopleServed: (NSString *) peopleServed andEmployeesClock: (NSString *) employeesClock];
[arrayOfStore addObject:myStore];
But it's returning the error message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8ddb930'
What does this error mean?
EDIT: I extended my code a bit.