Skip to content

Commit

Permalink
Merge pull request #77 from viktorasl/feature/mutex-lock-static
Browse files Browse the repository at this point in the history
Mutex lock static variables
  • Loading branch information
matthewcheok committed Jan 6, 2016
2 parents 631f22d + a438bdf commit 32d7454
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Realm+JSON.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
67 changes: 36 additions & 31 deletions Realm+JSON/RLMObject+JSON.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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;
}
Expand Down

0 comments on commit 32d7454

Please sign in to comment.