Based on the accepted answer to this answer, I am trying to send an array of custom objects via JSON to a server.
However, the following code to serialize the objects is crashing. I think it because NSJSONSerialization can only accept an NSDictionary, not a custom object.
NSArray <Offers *> *offers = [self getOffers:self.customer];
//Returns a valid array of offers as far as I can tell.
NSError *error;
//Following line crashes
NSData * JSONData = [NSJSONSerialization dataWithJSONObject:offers
options:kNilOptions
error:&error];
Can anyone suggest way to convert an array of custom objects to JSON?