开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜