I have been using NSJSONSerialization class for converting fields of my object to JSON. Sadly only NSString, NSNumber, NSArray, NSDictionary, or NSNull types are supported.
As my object has one additional field, that is UIImage, I am at loss as to how to deal with it. I am sure many people have encountered this common problem, so what is best method to approach this?
You can encode
UIImagedata by base64, and add it to json object.To get data from UIImage, you can use
UIImagePNGRepresentationandUIImageJPEGRepresentation.The code like this,
To restore
UIImagedata, just parse json object and decode the data by base64.Hope this can help you.