• 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
Archiving strategy - comments please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Archiving strategy - comments please
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Re: Passing data to Core Data model
  • Next by Date: Multiple movable modals
  • Previous by thread: Re: Representing hierarchy in NSPopupButtonCell
  • Next by thread: Re: Archiving strategy - comments please
  • Index(es):
    • Date
    • Thread