• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Ordered lists WAS ADC Core Data article
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: ADC Core Data article (From: Philippe Mougin <email@hidden>)
 >Re: ADC Core Data article (From: Shawn Erickson <email@hidden>)
 >Re: ADC Core Data article (From: Ralph Scheuer <email@hidden>)
 >Re: ADC Core Data article (From: John Brownlow <email@hidden>)
 >Ordered lists WAS ADC Core Data article (From: John Brownlow <email@hidden>)

  • Prev by Date: NSFileHandleReadCompletionNotification(s) not being posted when app is inactive
  • Next by Date: NSBezierPath line
  • Previous by thread: Re: Ordered lists WAS ADC Core Data article
  • Next by thread: Re: Ordered lists WAS ADC Core Data article
  • Index(es):
    • Date
    • Thread