Skip to content

Commit 9392726

Browse files
committed
Updated for Realm 0.91
1 parent b5a5188 commit 9392726

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Realm+JSON.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Realm+JSON'
3-
s.version = '0.2.5'
3+
s.version = '0.2.6'
44
s.ios.deployment_target = '7.0'
55
s.osx.deployment_target = '10.8'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
1616
s.source_files = 'Realm+JSON/*.{h,m}'
1717
s.public_header_files = 'Realm+JSON/*.h'
1818

19-
s.dependency 'Realm', '~> 0.90'
19+
s.dependency 'Realm', '~> 0.91'
2020
end

Realm+JSON/RLMObject+JSON.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,21 @@ + (RLMObjectSchema *)sharedSchema;
5656

5757
@implementation RLMObject (JSON)
5858

59+
static NSInteger const kCreateBatchSize = 100;
60+
5961
+ (NSArray *)createOrUpdateInRealm:(RLMRealm *)realm withJSONArray:(NSArray *)array {
62+
NSInteger count = array.count;
6063
NSMutableArray *result = [NSMutableArray array];
6164

62-
for (NSDictionary *dictionary in array) {
63-
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
64-
[result addObject:object];
65+
for (NSInteger index=0; index*kCreateBatchSize<count; index++) {
66+
NSInteger size = MIN(kCreateBatchSize, count-index*kCreateBatchSize);
67+
@autoreleasepool {
68+
for (NSInteger subIndex=index*kCreateBatchSize; subIndex<size; subIndex++) {
69+
NSDictionary *dictionary = array[subIndex];
70+
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
71+
[result addObject:object];
72+
}
73+
}
6574
}
6675

6776
return [result copy];

0 commit comments

Comments
 (0)