0

the situation is here: I use JsonModel to convert json to model when I get data from API, it's pretty good.

and I have to do persistent storage for some data, I finally choose NSKeyedArchive and NSKeyedUnarchive to save and fetch data. now comes the point, the JsonModel has already conform to NSCoding, so I don't need to write the code to apply the NSCoding. I archive and unarchive some basic data, it works well.

but there is a UIImage property in a data model ,when I archive the data model, the problem comes, the archive does not complete. (it seems the JsonModel does not support UIImage coding???)

when it throw out ,the code comes to

@throw [NSException exceptionWithName:@"Value transformer not found"
                                                   reason:[NSString stringWithFormat:@"[JSONValueTransformer %@] not found", selectorName]
                                                 userInfo:nil];

so any body knows what should i do to solve the problem?

thanks ahead!

childrenOurFuture
  • 1,889
  • 2
  • 14
  • 23

1 Answers1

1

You're correct - JSONModel does not support (de)serialization of UIImage instances. You should implement a custom data transformer (JSONValueTransformer), as shown in the readme:

@implementation JSONValueTransformer (CustomTransformer)

- (UIImage *)UIImageFromNSString:(NSString *)string {
    return nil; // transformed object
}

- (NSString *)JSONObjectFromUIImage:(UIImage *)image {
    return nil; // transformed object
}

@end
James Billingham
  • 760
  • 8
  • 32