accessing plists on iphone simulator
-
22-08-2019 - |
Question
So I have started building plist files using NSCoder, but as I"m developing i want to look at them and see what data is being saved.
How do i find/access the plist files generated by my app in the simulator (and on the device when i get to that)
Places Ive looked:
- application bundle
- build directory
Solution
To put them into the ~/Library/Application Support/iPhone Simulator/User/Applications/ subfolder (where they would end up if they were on a real device), you could use the following piece of code in your application:
+ (NSString *)dataFilePath:(NSString *)filename {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:filename];
}
This will put the file in the /Documents/ folder of your application's sandbox. You can then find the file back at: ~/Library/Application Support/iPhone Simulator/User/Applications/ Application GUID /Documents/
Good luck.
OTHER TIPS
wow that is dumb,
found them at /
this simulator must not emulate the real phone environment well at all.
If your plist is in the Document folder then give the path as
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
else if your plist file is in the resource folder then give the path of resource folder as
[[NSBundle mainbundle] pathforresources:..........];