Re: Handling Multiple Document Types
Re: Handling Multiple Document Types
- Subject: Re: Handling Multiple Document Types
- From: acoolie <email@hidden>
- Date: Sun, 8 Jul 2007 22:55:47 -0400
I have a NSDocument application which should handle two types of document.
One document will be an actual file and the other will not. My current
working solution is to determine which type of document the document is in
MyDocument, storing it in an instance variable, then using a simple if-else
in all methods to run different code for each document type.
I figured that it might be easier to instead have MyDocument, then
two subclasses of MyDocument, DocumentA and DocumentB. MyDocument
will determine if it should be DocumentA or DocumentB in any method
(not necessarily init). I am not quite sure how I would go about this.
I figure using self = [[DocumentA alloc] init]; would be a bad idea since
DocumentA-init would call -init on the MyDocument again too.
After searching around a little bit, I found some code for returning a
subclass of the class in init or in a factory class. This solution sounds
reasonable but my problem is since I am using the NSDocument architecture
the -init method is called before the document is actually loaded in
readFromData: or readFromURL:
I have a feeling this solution is entirely unnecessary and there is either a
much easier solution to this or my current solution is fine. Any help would
be appreciated, I am not very attached to my current method so if you can
solve my issue without solving the subclass problem that would be fine.
-ACoolie
_______________________________________________
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:
This email sent to email@hidden