Looking for an example of how to post json with AFHTTPClient. I see that there is a postPath method which takes an NSDictionary and the AFJSONEncode method returns an NSData. Is there an easy way to serialize an object to NSDictionary, or is there an easier way using jsonkit?
I just need to post the object as json to a REST API.
UPDATE: So I tried passing a dictionary over but it seems to break on serializing a nested array.
For example, if I have an object:
Post* p = [[Post alloc] init];
p.uname = @"mike";
p.likes =[NSNumber numberWithInt:1];
p.geo = [[NSArray alloc] initWithObjects:[NSNumber numberWithFloat:37.78583], [NSNumber numberWithFloat:-122.406417], nil ];
p.place = @"New York City";
p.caption = @"A test caption";
p.date = [NSDate date];
who's get dictionary has data like the following:
{
caption = "A test caption";
date = "2011-12-13 17:58:37 +0000";
geo = (
"37.78583",
"-122.4064"
);
likes = 1;
place = "New York City";
}
the serialization will either just fail outright or geo will not be serialized as an array but as a string literal like ("37.78583", "-122.4064");