views:

86

answers:

2

Are the permissions for the iphone/ipad simulator different from the device itself? I only ask because I'm experimenting with file I/O, and creating and then writing to my own temporary file fails, but creating and writing to, say, the Desktop on my Mac (from the iPad simulator) is completely okay.

Am I doing something wrong with my tempfile creation on the simulator?

+1  A: 

Do you use the temporary directory? On Simulator NSTemporaryDirectory() returns Mac OS X tmp, a path in /var, which is outside the application sandbox.

#if TARGET_IPHONE_SIMULATOR
NSString *tmpPath = [NSHomeDirectory() stringByAppendingPathComponent: @"tmp"];
#else
NSString *tmpPath = NSTemporaryDirectory();
#endif
Costique
+1  A: 

The permissions are different. On the simulator you can write outside the app's directory and on device you cannot. If you could on device, you alter other apps or attack the operating system.

TechZen
Thanks a lot, this is good to know. For those stumbling here hoping for more help, using writeToFile rather than writeToURL and targeting within the App's directory solved it.
mtc06