Rather than subclassing, you're much better off using a category along these lines:

@interface NSDictionary (CustomDataFormat)
- (id)initWithCustomData:(NSData *)data;
- (id)initWithCustomDataContentsOfURL:(NSURL *)URL;
- (NSData *)customData;
- (BOOL)writeToURL:(NSURL *)URL atomically:(BOOL)atomically error: (NSError **)error;
@end


When implementing these methods:
* It may be easier to use class methods rather than custom -init… ones.
* Pay attention to how the methods handle being called for NSMutableDictionary rather than NSDictionary. You may need to provide a second, subclass implementation in some cases.

Mike.

On 5 Dec 2008, at 09:08, Mark Thomas wrote:

Hi All,
 Does anybody have any thoughts on how you could subclass or hook into
NSDictionary/NSMutableDictionary classes, so that I could provide my own file format instead of the default file format which are used today (i.e. Text or binary plist format). As I still want the flexibility of dictionary
but I don't want the default file formats.

 Ideally it would be good if I could create
NSDictionary/NSMutableDictionary with a NSData object, but there doesn't
seem to be a way to pass in the info this way.

Thanks
Mark.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to