accessing data saved in the iPhone simulator
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:
开发者_JAVA百科 @"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?
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.
精彩评论