Skip to content

Commit

Permalink
Updated for Realm 0.91
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcheok committed Mar 11, 2015
1 parent b5a5188 commit 9392726
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions 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.5'
s.version = '0.2.6'
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.8'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand All @@ -16,5 +16,5 @@ Pod::Spec.new do |s|
s.source_files = 'Realm+JSON/*.{h,m}'
s.public_header_files = 'Realm+JSON/*.h'

s.dependency 'Realm', '~> 0.90'
s.dependency 'Realm', '~> 0.91'
end
15 changes: 12 additions & 3 deletions Realm+JSON/RLMObject+JSON.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,21 @@ + (RLMObjectSchema *)sharedSchema;

@implementation RLMObject (JSON)

static NSInteger const kCreateBatchSize = 100;

+ (NSArray *)createOrUpdateInRealm:(RLMRealm *)realm withJSONArray:(NSArray *)array {
NSInteger count = array.count;
NSMutableArray *result = [NSMutableArray array];

for (NSDictionary *dictionary in array) {
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
[result addObject:object];
for (NSInteger index=0; index*kCreateBatchSize<count; index++) {
NSInteger size = MIN(kCreateBatchSize, count-index*kCreateBatchSize);
@autoreleasepool {
for (NSInteger subIndex=index*kCreateBatchSize; subIndex<size; subIndex++) {
NSDictionary *dictionary = array[subIndex];
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
[result addObject:object];
}
}
}

return [result copy];
Expand Down

0 comments on commit 9392726

Please sign in to comment.