matthewcheok / Realm-JSON

A concise Mantle-like way of working with Realm and JSON.
MIT License
661 stars 129 forks source link

Fix incorrect inner loop when batching createOrUpdateInRealm:withJSONDictionary: calls #38

Closed dcramps closed 9 years ago

dcramps commented 9 years ago

Current implementation incorrectly stops running the inner loop after the first 100 objects, since index*kCreateBatchSize < size is always false after the first run of the outer loop.

With some logging, this is what I'm seeing:

array size: 456 index: 0, subIndex: 0, size: 100 index: 1, subIndex: 100, size: 100 index: 2, subIndex: 200, size: 100 index: 3, subIndex: 300, size: 100 index: 4, subIndex: 400, size: 56 total calls to createOrUpdateInRealm:withJSONDictionary: was 100

As well as confirming with [RLMRealm allObjects] giving me no more than 100 objects.