Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lazy Loading Archive




On 25 Aug 2008, at 11:56 pm, Graff wrote:

I have a large class I'm archiving that I would like to lazy-load. It's basically a wrapper around a NSArray and what I'd like to do is load some instance variables but leave the array archived until a later time in order to save time and memory.

When I implement the NSCoding protocol methods initWithCoder: and encodeWithCoder: is it a bad idea to de-archive the keys that I need and just retain the NSCoder object so that I can later de-archive the NSArray? Is there any problem keeping the NSCoder object around for long periods of time? Is there a better way of doing this?

I'd hate to have to archive two separate objects in order to implement this, one which is the actual class with a placeholder array and then the large array separately, but I guess that's another way to go.


How large are you talking about?

Have you actually profiled to see whether there is some genuine reason for wanting to do this, or are you just going on a "gut feeling" that it might be slow?

I'm not sure whether NSCoder preloads the entire archive into memory or not, but if it does and you retain the coder, you won't be saving time and memory anyway - in fact it could be worse on memory - much worse if your archive uses XML format. If it ends up being necessary there are solutions. Separate archives is one way, and that could be combined with packaging your document.

cheers, Grham
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Lazy Loading Archive (From: Graff <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.