From bed0efa01d6d9aae078ca36c54fc1fcf47185f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktoras=20Laukevic=CC=8Cius?= Date: Fri, 18 Dec 2015 09:55:06 +0200 Subject: [PATCH 1/2] Mutex lock for static variables --- Realm+JSON/RLMObject+JSON.m | 67 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/Realm+JSON/RLMObject+JSON.m b/Realm+JSON/RLMObject+JSON.m index cb37a55..93acf40 100644 --- a/Realm+JSON/RLMObject+JSON.m +++ b/Realm+JSON/RLMObject+JSON.m @@ -294,19 +294,20 @@ + (NSDictionary *)mc_inboundMapping { dispatch_once(&onceToken, ^{ mappingForClassName = [NSMutableDictionary dictionary]; }); - - NSDictionary *mapping = mappingForClassName[[self className]]; - if (!mapping) { - SEL selector = NSSelectorFromString(@"JSONInboundMappingDictionary"); - if ([self respondsToSelector:selector]) { - mapping = MCValueFromInvocation(self, selector); - } - else { - mapping = [self mc_defaultInboundMapping]; - } - mappingForClassName[[self className]] = mapping; - } - return mapping; + @synchronized(mappingForClassName) { + NSDictionary *mapping = mappingForClassName[[self className]]; + if (!mapping) { + SEL selector = NSSelectorFromString(@"JSONInboundMappingDictionary"); + if ([self respondsToSelector:selector]) { + mapping = MCValueFromInvocation(self, selector); + } + else { + mapping = [self mc_defaultInboundMapping]; + } + mappingForClassName[[self className]] = mapping; + } + return mapping; + } } + (NSDictionary *)mc_outboundMapping { @@ -316,18 +317,20 @@ + (NSDictionary *)mc_outboundMapping { mappingForClassName = [NSMutableDictionary dictionary]; }); - NSDictionary *mapping = mappingForClassName[[self className]]; - if (!mapping) { - SEL selector = NSSelectorFromString(@"JSONOutboundMappingDictionary"); - if ([self respondsToSelector:selector]) { - mapping = MCValueFromInvocation(self, selector); - } - else { - mapping = [self mc_defaultOutboundMapping]; - } - mappingForClassName[[self className]] = mapping; - } - return mapping; + @synchronized(mappingForClassName) { + NSDictionary *mapping = mappingForClassName[[self className]]; + if (!mapping) { + SEL selector = NSSelectorFromString(@"JSONOutboundMappingDictionary"); + if ([self respondsToSelector:selector]) { + mapping = MCValueFromInvocation(self, selector); + } + else { + mapping = [self mc_defaultOutboundMapping]; + } + mappingForClassName[[self className]] = mapping; + } + return mapping; + } } + (RLMProperty *)mc_propertyForPropertyKey:(NSString *)key { @@ -349,12 +352,14 @@ + (Class)mc_classForPropertyKey:(NSString *)key { set = [NSCharacterSet characterSetWithCharactersInString:@"\"<"]; }); - NSString *string; - NSScanner *scanner = [NSScanner scannerWithString:attributes]; - scanner.charactersToBeSkipped = set; - [scanner scanUpToCharactersFromSet:set intoString:NULL]; - [scanner scanUpToCharactersFromSet:set intoString:&string]; - return NSClassFromString(string); + @synchronized(set) { + NSString *string; + NSScanner *scanner = [NSScanner scannerWithString:attributes]; + scanner.charactersToBeSkipped = set; + [scanner scanUpToCharactersFromSet:set intoString:NULL]; + [scanner scanUpToCharactersFromSet:set intoString:&string]; + return NSClassFromString(string); + } } return nil; } From a438bdf46da21ceccc3a0a36488ff738d47edf2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktoras=20Laukevic=CC=8Cius?= Date: Wed, 6 Jan 2016 09:26:13 +0200 Subject: [PATCH 2/2] Bumped pod version 0.2.13 --- Realm+JSON.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Realm+JSON.podspec b/Realm+JSON.podspec index 7ec97c6..2f77273 100644 --- a/Realm+JSON.podspec +++ b/Realm+JSON.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Realm+JSON' - s.version = '0.2.12' + s.version = '0.2.13' s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.watchos.deployment_target = '2.0'