Re: Ordered lists WAS ADC Core Data article
Re: Ordered lists WAS ADC Core Data article
- Subject: Re: Ordered lists WAS ADC Core Data article
- From: Marcel Weiher <email@hidden>
- Date: Sat, 9 Apr 2005 00:09:13 +0100
On 8 Apr 2005, at 19:09, John Brownlow wrote:
I have a lot of toys in my bedroom, which is very untidy. Currently
when I go to bed (which I call 'Saving') I have to put all the toys
into their neat little boxes (NSCoding). This is very tiring.
Why do you find this tiring? I find it very, very easy, especially
with the encoding macros in, you guessed it *g*, MPWFoundation:
encodeVar( coder, var )
So for example, take the the following class definition:
@interface Employee : NSObject
{
id name;
id age;
id salary;
}
@end
You can the encode your ivars as follows:
-(void)encodeWithCoder:(NSCoder*)coder
{
[super encodeWithCoder:coder];
encodeVar( coder, name );
encodeVar( coder, age );
encodeVar( coder, salary );
}
For a specific project, I also implemented a generic coding method
that would simply encode a list of instance variables, with that list
defaulting to the object's instance variables. So automagic encoding
for all subclasses (with an optional exception list).
Cheers,
Marcel
_______________________________________________
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