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

The best way to archive dependancies


  • Subject: The best way to archive dependancies
  • From: Francisco Tolmasky <email@hidden>
  • Date: Sun, 11 May 2003 15:17:33 -0700

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.

  • Follow-Ups:
    • Re: The best way to archive dependancies
      • From: publiclook <email@hidden>
  • Prev by Date: Best way to build relative pathname?
  • Next by Date: Re: NSTextStorage: efficient way to find a specific attribute?
  • Previous by thread: Re: Best way to build relative pathname?
  • Next by thread: Re: The best way to archive dependancies
  • Index(es):
    • Date
    • Thread