• 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: The best way to archive dependancies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The best way to archive dependancies


  • Subject: Re: The best way to archive dependancies
  • From: publiclook <email@hidden>
  • Date: Sun, 11 May 2003 19:48:19 -0400

What you propose doing works fine.

You can also look into conditional encoding if you don't want to _have_ to encode an entire object graph just to encode part of it.


"Cocoa Programming" has good description of all of this as I recall.


On Sunday, May 11, 2003, at 06:17 PM, Francisco Tolmasky wrote:

Ok, I have two classes something like this:

@interface A: NSObject
{
NSMutableArray *Bs;
}
@end

@interface B: NSObject
{
A * parentA;
}
@end

For one reason or another, I need all the B's stored in A to know whom their parent A is. Now, this is all good and dandy, until I need to archive. I know that NSArchiver archives references when it encounters the same object more than once, but I don't know if this applies here:


@implementation A

- (id)initWithCoder:(NSCoder *)aCoder
{
self= [super init];
if(self) Bs= [[aCoder decodeObject] retain];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
[Bs encodeWithCoder: aCoder];
}

@end

@implementation B

- (id)initWithCoder:(NSCoder *)
{
self= [super init];
if(self) parentA= [aCoder decodeObject];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
[parent encodeWithCoder: aCoder];
}

@end

Is this correct? Will this work? Or will it be circular and crash? Is there a different way of doing this, making some sort of initWithCoder:parentA: message, subclassing nscoder to have a decodeObjectWithDependancy: ?

Thank you in advance.

Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >The best way to archive dependancies (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: NSTextStorage: efficient way to find a specific attribute?
  • Next by Date: Re: weird problem ...
  • Previous by thread: The best way to archive dependancies
  • Next by thread: [ANNOUNCE] GeekTool 2.0
  • Index(es):
    • Date
    • Thread