Archiving strategy - comments please
Archiving strategy - comments please
- Subject: Archiving strategy - comments please
- From: Andy Bettis <email@hidden>
- Date: Tue, 14 Jun 2005 13:31:50 +0100
Hi folks,
I'm still writing my first Cocoa app and am starting on my saving and
loading routines. I have an array of objects which are subclasses of a
subclass of NSObject and I need to write the NSCoding protocol methods
for these.
In my superclass I have the method:
- (id) initWithCoder:(NSCoder*) inCoder
{
if (self = [super init]) {
[self setName:[inCoder decodeObjectForKey:@"name"]];
[self setID:[inCoder decodeLongForKey:@"ID"]];
}
return(self);
}
(I know decodeLongForKey isn't there any more - should I use int?
int32_t? I still have an instictive fear of int from back when you
weren't sure of the size, and I need 32 bits for these.)
In the subclass I will have:
- (id) initWithCoder:(NSCoder*) inCoder
{
if (self = [super initWithCoder:inCoder]) {
[self setIncome:[inCoder decodeBoolForKey:@"income"]];
[self setIExpenditure:[inCoder decodeBoolForKey:@"expenditure"]];
}
return(self);
}
Does this all look OK? I will add containsValueForKey calls when I get
to a production level.
As an aside, what is a good system for storing the key names in the
interface file? In my old (C++) system I kept an enum of single
character identifiers but it would be nice to have meaningful labels.
Can I set up static NSStrings?
Thanks in advance
Rev. Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden