diff --git a/MJExtension.podspec b/MJExtension.podspec index f312ea72..d7b49627 100644 --- a/MJExtension.podspec +++ b/MJExtension.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MJExtension" - s.version = "3.0.11" + s.version = "3.0.12" s.ios.deployment_target = '6.0' s.osx.deployment_target = '10.8' s.summary = "A fast and convenient conversion between JSON and model" diff --git a/MJExtension/MJPropertyType.m b/MJExtension/MJPropertyType.m index b78b2028..384beba5 100755 --- a/MJExtension/MJPropertyType.m +++ b/MJExtension/MJPropertyType.m @@ -22,14 +22,15 @@ + (void)initialize + (instancetype)cachedTypeWithCode:(NSString *)code { MJExtensionAssertParamNotNil2(code, nil); - - MJPropertyType *type = types_[code]; - if (type == nil) { - type = [[self alloc] init]; - type.code = code; - types_[code] = type; + @synchronized (self) { + MJPropertyType *type = types_[code]; + if (type == nil) { + type = [[self alloc] init]; + type.code = code; + types_[code] = type; + } + return type; } - return type; } #pragma mark - 公共方法 diff --git a/MJExtension/NSObject+MJClass.m b/MJExtension/NSObject+MJClass.m index 789b9a89..46447a86 100644 --- a/MJExtension/NSObject+MJClass.m +++ b/MJExtension/NSObject+MJClass.m @@ -34,11 +34,13 @@ + (void)load + (NSMutableDictionary *)dictForKey:(const void *)key { - if (key == &MJAllowedPropertyNamesKey) return allowedPropertyNamesDict_; - if (key == &MJIgnoredPropertyNamesKey) return ignoredPropertyNamesDict_; - if (key == &MJAllowedCodingPropertyNamesKey) return allowedCodingPropertyNamesDict_; - if (key == &MJIgnoredCodingPropertyNamesKey) return ignoredCodingPropertyNamesDict_; - return nil; + @synchronized (self) { + if (key == &MJAllowedPropertyNamesKey) return allowedPropertyNamesDict_; + if (key == &MJIgnoredPropertyNamesKey) return ignoredPropertyNamesDict_; + if (key == &MJAllowedCodingPropertyNamesKey) return allowedCodingPropertyNamesDict_; + if (key == &MJIgnoredCodingPropertyNamesKey) return ignoredCodingPropertyNamesDict_; + return nil; + } } + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration diff --git a/MJExtension/NSObject+MJProperty.m b/MJExtension/NSObject+MJProperty.m index fd7197a0..2314c460 100644 --- a/MJExtension/NSObject+MJProperty.m +++ b/MJExtension/NSObject+MJProperty.m @@ -44,12 +44,14 @@ + (void)load + (NSMutableDictionary *)dictForKey:(const void *)key { - if (key == &MJReplacedKeyFromPropertyNameKey) return replacedKeyFromPropertyNameDict_; - if (key == &MJReplacedKeyFromPropertyName121Key) return replacedKeyFromPropertyName121Dict_; - if (key == &MJNewValueFromOldValueKey) return newValueFromOldValueDict_; - if (key == &MJObjectClassInArrayKey) return objectClassInArrayDict_; - if (key == &MJCachedPropertiesKey) return cachedPropertiesDict_; - return nil; + @synchronized (self) { + if (key == &MJReplacedKeyFromPropertyNameKey) return replacedKeyFromPropertyNameDict_; + if (key == &MJReplacedKeyFromPropertyName121Key) return replacedKeyFromPropertyName121Dict_; + if (key == &MJNewValueFromOldValueKey) return newValueFromOldValueDict_; + if (key == &MJObjectClassInArrayKey) return objectClassInArrayDict_; + if (key == &MJCachedPropertiesKey) return cachedPropertiesDict_; + return nil; + } } #pragma mark - --私有方法--