O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Archiving objects into archive files

The classes NSKeyedArchiver and NSKeyedUnarchiver allow us to persist data in a very Object-oriented way. By conforming to the NSCoding protocol, we can tell the archiver how to pack and unpack any of our classes. In this recipe, we will be packing up a character who has a number of Dungeons and Dragons style attributes.

Archiving objects into archive files

Getting ready

Please refer to the project RecipeCollection01 for full working code of this recipe. Also note that some of the following code has been omitted for brevity.

How to do it...

Execute the following code:

//SimpleCharacter.h @interface SimpleCharacter : NSObject <NSCoding> { NSString *charColor; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required