I have an objective C class like,
@interface message : NSObject {
NSString *from;
NSString *date;
NSString *msg;
}
I have an NSMutableAr
Note: This will only work with serializable objects. This answer was provided above in an edit to the question itself, but I always look for answers in the "answers" section myself ;-)
- (NSString*) convertObjectToJson:(NSObject*) object
{
NSError *writeError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object options:NSJSONWritingPrettyPrinted error:&writeError];
NSString *result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
return result;
}