Search code examples
iphoneobjective-cmemorynskeyedarchiver

Loading a large dataset in chunks on Iphone using NSkeyedArchiver


I have a large NSDictionary thats written to disk using NSkeyedArchiver. Since this dictionary may/will be very large, its not feasible to load the entire thing into memory. Whats the best best way to load up the dictionary in chunks,work with that chunk and then move on to the next etc and hence save up on memory.


Solution

  • Don't use NSkeyedArchiver to archive one big NSDictionary containing all objects.

    Archive objects using encodeObject:forKey: unarchive using decodeObjectForKey:.
    This way you don't need to unarchive the whole NSDictionary in order to retrieve just one object.