• 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: NSArchiver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArchiver


  • Subject: Re: NSArchiver
  • From: tyler <email@hidden>
  • Date: Fri, 10 Aug 2001 22:27:39 -0700

On Saturday, August 11, 2001, at 07:28 PM, stuartbryson wrote:

Hi all,

In my program I create various 3D objects within a Build function. I want to however save these 3D objects to file so I can just import them when I run. I thought NSArchiver would do the trick. I started with the code below:

Object3D *tempObj;
NSArchiver *tempArchive;

tempObj = [[[Sphere alloc] init] autorelease];
[tempObj setRadius:85.0];
[tempObj setColour:[[[RGBVector alloc] initWithValuesRed:1.0 green:0.0 blue:0.0]autorelease]];
[self addThreeDObject:tempObj];

this next line uses tempArchive which is nil since it's never been initialized. For a class method you want something like: [NSArchiver archiveRootObject: ...]; you send the message (method call) to the CLASS because it's a class method.

if (![tempArchive archiveRootObject:tempObj toFile:@"/MyPath/3dObject"]);
NSLog(@"File was not archived");

This does not work however... I am not sure why but the compiler says that NSArchiver does not respond to archiveRootObject... I checked the doco and perhaps I do not understand how to use the + methods in each class. I understand that + methods are class methods and not instance methods?

Any help on this would be appreciated. Perhaps NSArchiver isn't even the way to go?

No, NSArchiver should work fine. It's pretty cool. Now your objects have to implement the NSCoding protocol in order to be archived and read back in.

luck,
tyler


References: 
 >NSArchiver (From: stuartbryson <email@hidden>)

  • Prev by Date: Re: WriteToFile:atomically: question
  • Next by Date: Locking sizeToFit
  • Previous by thread: NSArchiver
  • Next by thread: Re: NSArchiver
  • Index(es):
    • Date
    • Thread