views:

124

answers:

2

I have an app and it stores data to a .plist file in the resources group in Xcode (if that matters). And whenever I run it on the simulator it works perfectly with the file. On the iPhone, however, it doesn't seem to be interacting with the file.

Thanks in advance!

+4  A: 

You cannot write to the application bundle on the device. It is read-only. You have to write your file to your app's Documents folder.

Ole Begemann
I think this is your problem. When you try to write to a file within your app bundle, simulator allows you. After all, it's not a "emulator" that exactly emulates what you get on iPhone. However, trying to write to the same file on iPhone OS will fail.
Mugunth Kumar
+2  A: 

Here's an example of how to get Documents directory path, you should write any user data there:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
kovpas