dictionary - How to hook into Mantle -
i'm using mantle , fits basic need. after declaring jsonkeypathsbypropertykey
, propertyjsontransformer
, can turn json dictionary object
etpuser *user = [mtljsonadapter modelofclass:[etpuser class] fromjsondictionary:jsondict error:nil];
now want hook transformation process other complex fields (setting other properties not declared in jsonkeypathsbypropertykey
) in jsondict
, can't find ways this
how hook mantle ?
try snippet:
- (id)initwithdictionary:(nsdictionary *)dictionary error:(nserror *__autoreleasing *)error { nsdictionary *hookedvalue = [[nsdictionary alloc] initwithobjectsandkeys: @"defaultvalue1", @"defaultkey1", @"defaultvalue2", @"defaultkey2", @"defaultvalue3", @"defaultkey3", nil]; dictionary = [hookedvalue mtl_dictionarybyaddingentriesfromdictionary:dictionary]; return [super initwithdictionary:dictionary error:error]; }
Comments
Post a Comment