• 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: Brian Webster <email@hidden>
  • Date: Sat, 11 Aug 2001 12:34:40 -0500

On Saturday, August 11, 2001, at 12:15 AM, cocoa-dev-
email@hidden wrote:

<code snipped>

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?

When you call a class method, you send the message to the class object rather than one of the instances of the class. You do this by putting the name of the class in the method call rather than a variable. So what you want is:

[NSArchiver archiveRootObject:tempObject toFile:@"/MyPath/3dObject"];

This is basically a shorthand for:

NSMutableData *archivedData = [[NSMutableData alloc] init];
NSArchiver *myArchiver = [[NSArchiver alloc] initWithMutableData:archivedData];

[myArchiver encodeRootObject:tempObj]; //puts the data into archivedData
[archivedData writeToFile:@"/MyPath/3dObject" atomically:YES]; //writes the data to disk
[myArchiver release];
[archivedData release];

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: Portable Network Graphics format
  • Next by Date: NSCursor
  • Previous by thread: Re: NSArchiver
  • Next by thread: Locking sizeToFit
  • Index(es):
    • Date
    • Thread