File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11Pod ::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 '
2020end
Original file line number Diff line number Diff 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 ];
You can’t perform that action at this time.
0 commit comments