访问 iPhone 模拟器中保存的数据
我正在开发一款游戏,我想为非开发人员朋友提供一个小关卡编辑器,以便他们可以在我继续开发的同时构建关卡。
我快速敲出以下内容,看看它是否会创建一个文件,我的朋友可以复制并通过电子邮件发送给我以供以后使用。
// Archive Test
NSMutableDictionary *leveldata = [NSDictionary
dictionaryWithObjectsAndKeys:
@"This is value 1", @"key1",
@"This is value 2", @"key2",
nil];
NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:gamestate];
if([myData writeToFile:@"gamestate.bin" atomically:YES]){
NSLog(@"SAVED");
}else{
NSLog(@"FAIL SAVE");
}
根据日志,已经保存了。但是,我不知道在哪里,我假设进入应用程序 tmp 或文档目录。但是我是否可以调整它以使保存的数据可以在模拟器之外访问,或者我应该采取另一种方法吗?
I'm working on a game and I'd like to give a non-developer friend a little level editor so they can build levels while I continue working on the development.
I quickly knocked up the following to see if it would create a file my friend could copy and email to me for later use.
// Archive Test
NSMutableDictionary *leveldata = [NSDictionary
dictionaryWithObjectsAndKeys:
@"This is value 1", @"key1",
@"This is value 2", @"key2",
nil];
NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:gamestate];
if([myData writeToFile:@"gamestate.bin" atomically:YES]){
NSLog(@"SAVED");
}else{
NSLog(@"FAIL SAVE");
}
According to the log, it's been saved. However, I've no idea where, I assume into the applications tmp or document directory. But is there anyway I can tweak this to make that saved data accessible outside of the simulator, or is there another approach I should take?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
他们进入目录:“~/Library/Application Support/iPhone Simulator/User/Applications/xxx,其中 xxx 是 36 个字符的唯一 ID,您必须找到正确的 ID,我通常只检查修改日期。请注意路径中的空格字符。
They go into the directory: "~/Library/Application Support/iPhone Simulator/User/Applications/xxx where xxx is a 36 character unique ID, you will have to find the correct one, I usually just check the modification date. Be aware of the space characters in the path.