File Permissions On The iPhone Simulator
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 te开发者_运维技巧mporary 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?
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
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.
精彩评论