Skip to content

Commit

Permalink
多线程支持
Browse files Browse the repository at this point in the history
解决多线程环境下的Crash问题
  • Loading branch information
520dev committed Jul 21, 2016
1 parent 498303d commit 5e9f2f5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion 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"
Expand Down
15 changes: 8 additions & 7 deletions MJExtension/MJPropertyType.m
Expand Up @@ -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 - 公共方法
Expand Down
12 changes: 7 additions & 5 deletions MJExtension/NSObject+MJClass.m
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions MJExtension/NSObject+MJProperty.m
Expand Up @@ -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 - --私有方法--
Expand Down

0 comments on commit 5e9f2f5

Please sign in to comment.