|
@@ -419,6 +419,8 @@ static force_inline id YYValueForMultiKeys(__unsafe_unretained NSDictionary *dic
|
|
|
YYEncodingNSType _nsType;
|
|
|
|
|
|
BOOL _hasCustomTransformFromDictionary;
|
|
|
+ BOOL _hasCustomWillTransformFromDictionary;
|
|
|
+
|
|
|
BOOL _hasCustomTransformToDictionary;
|
|
|
BOOL _hasCustomClassFromDictionary;
|
|
|
}
|
|
@@ -561,7 +563,8 @@ static force_inline id YYValueForMultiKeys(__unsafe_unretained NSDictionary *dic
|
|
|
_hasCustomTransformFromDictionary = ([cls instancesRespondToSelector:@selector(modelCustomTransformFromDictionary:)]);
|
|
|
_hasCustomTransformToDictionary = ([cls instancesRespondToSelector:@selector(modelCustomTransformToDictionary:)]);
|
|
|
_hasCustomClassFromDictionary = ([cls respondsToSelector:@selector(modelCustomClassForDictionary:)]);
|
|
|
-
|
|
|
+ _hasCustomWillTransformFromDictionary = ([cls instancesRespondToSelector:@selector(modelCustomWillTransformFromDictionary:)]);
|
|
|
+
|
|
|
return self;
|
|
|
}
|
|
|
|
|
@@ -1422,13 +1425,21 @@ static NSString *ModelDescription(NSObject *model) {
|
|
|
if (!dic || dic == (id)kCFNull) return NO;
|
|
|
if (![dic isKindOfClass:[NSDictionary class]]) return NO;
|
|
|
|
|
|
+
|
|
|
_YYModelMeta *modelMeta = [_YYModelMeta metaWithClass:object_getClass(self)];
|
|
|
if (modelMeta->_keyMappedCount == 0) return NO;
|
|
|
+
|
|
|
+ if (modelMeta->_hasCustomWillTransformFromDictionary) {
|
|
|
+ dic = [((id<YYModel>)self) modelCustomWillTransformFromDictionary:dic];
|
|
|
+ if (![dic isKindOfClass:[NSDictionary class]]) return NO;
|
|
|
+ }
|
|
|
+
|
|
|
ModelSetContext context = {0};
|
|
|
context.modelMeta = (__bridge void *)(modelMeta);
|
|
|
context.model = (__bridge void *)(self);
|
|
|
context.dictionary = (__bridge void *)(dic);
|
|
|
|
|
|
+
|
|
|
if (modelMeta->_keyMappedCount >= CFDictionaryGetCount((CFDictionaryRef)dic)) {
|
|
|
CFDictionaryApplyFunction((CFDictionaryRef)dic, ModelSetWithDictionaryFunction, &context);
|
|
|
if (modelMeta->_keyPathPropertyMetas) {
|