On 16/09/2013, at 4:25 PM, Chris Devereux <devereux.ch...@gmail.com> wrote:
> How about tracking the number of written objects when saving the document, > then encoding an additional key containing the object count at the top > level of the archive? This could then be retrieved before decoding the root > object. > > A possible problem with this idea is that it might require the data for the > root object to be read into memory before the count can be read. Maybe this > wouldn't be a problem with a binary format --- I don't know enough about > the implementation of NSKeyedArchiver/Unarchiver to be sure. I was thinking along these lines but I was hoping to come up with something that would work for existing archives that don't have the extra info. I don't know how much lazy loading NSKeyedUnarchiver does - it might get read or mapped into memory anyway. Perhaps there's a fairly quick way to count the number of objects in it? My file format is actually a package that has an auxiliary plist independent of the archive, so I could store a value there which would avoid loading the archive just to get that number, but that would only be for archives I write in future. --Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com