Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-29-2009, 01:03 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 15
Default save an entire game (a bunch of objects) without saving each object individually?

I know that I can manually go through every object and save them all, but is there a way to encapsulate and entire object, and everything that was created IN that object and save it all as 1 chunk of data?
or is that a horrible way to go about it?

I just can't imagine how nasty the code would be for me to record every individual piece of info that I'll need to save the game state fully..

Any ideas would be greatly appreciated!!
Thanks
__________________
Flu Fighter is out now!
iliketomakestuff is offline   Reply With Quote
Old 05-29-2009, 02:44 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Unfortunately, cocoa doesn't know which variables in your custom classes are important, and which are calculated or temporary. You need to code the methods for NSCoder so that the right variables get saved.

The good news is that if your custom objects conform to the NSCoder protocol, it's easy to use NSKeyedArchiver to save it to disk. You don't have to write your own code to write every variable to disk.

The Archives and Serializations Programming Guide should help
Archives and Serializations Programming Guide for Cocoa: Introduction
__________________

Free Games!
smasher is offline   Reply With Quote
Old 05-29-2009, 09:37 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 15
Default

Quote:
Originally Posted by smasher View Post
Unfortunately, cocoa doesn't know which variables in your custom classes are important, and which are calculated or temporary. You need to code the methods for NSCoder so that the right variables get saved.

The good news is that if your custom objects conform to the NSCoder protocol, it's easy to use NSKeyedArchiver to save it to disk. You don't have to write your own code to write every variable to disk.

The Archives and Serializations Programming Guide should help
Archives and Serializations Programming Guide for Cocoa: Introduction

sweet! thanks for answer! I don't know anything about NSCoder or NSKeyedArchiver, so I'll have to do some reading
__________________
Flu Fighter is out now!
iliketomakestuff is offline   Reply With Quote
Reply

Bookmarks

Tags
game, save, state

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 265
17 members and 248 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, jakerocheleau, JasonR, prchn4christ, Rudy, Speed, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:49 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0