On Aug 18, 2011, at 7:50 AM, Arno Oesterheld wrote: > I can not call [super initWithCoder] because NSDocument does not have such a > method. Should I call [self init] instead oder [super init]?
The advice you’ve gotten so far does not, unfortunately, address your basic problem, which is: Don’t make an archivable NSDocument. That isn’t how NSDocuments work. Your custom contents of the document should be archived, _not_ the NSDocument object itself. AppKit is going to instantiate your NSDocument subclass instance for you, and then ask it to load its contents from a given file/URL/NSData. That’s what you should be unarchiving. Then when the user says to save, AppKit will ask your document object to save its contents; you archive the contents (not the NSDocument itself) and write them out. Basically what you should do is define one or more classes that form your object model; then implement NSCoding in these classes. Your NSDocument subclass should have an instance variable pointing to the root model object. Now when the document is asked to load or save the data, it can archive/unarchive the root model object. —Jens
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com