English 中文(简体)
肉体游戏储蓄
原标题:iPhone game saves

How do I save game state in iPhone game? I have it all in NSDictionary. Some say use NSUserDefaults but that seems meant for things like volume. I can t find any official sample code that uses game saves. What is the apple way for saving game state?

问题回答

如果你只是想把该字典作为文件夹的标本,那将起到以下作用:

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* documentDir = [documentPaths objectAtIndex:0];
    NSString * savePath = [documentDir stringByAppendingPathComponent:@"save.plist"];
    [dict writeToFile: savePath atomically: YES];

It depends. NSUserDefaults are ok for a few or small things, but for larger things you might want to look at CoreData.

如果你使用核心数据管理所有贵国,那么你就能够节省费用并免费投入工作。 这正是大多数用户使用的,也是其数据储存的原因。

从NSDictionary向核心数据的过渡是直截了当的,但需要了解核心数据是如何运作的,并界定你的计划。

NSUserDefaults是而不是,用于挽救像游戏状态这样的东西,它被用于挽救像环境这样的东西。

存档是为了节省国际海洋观测系统的物体图表。 你们可以通过存档来恢复所挽救的完整状态。

http://developer.apple.com/library/ios/#documentation/coa/vis/foundation/Classes/NSKeyedArchiver_Class/Reference/Reference.html 较之<代码>NSUserDefaults更为灵活,但并非作为核心数据库的强大力量。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签