Xcode: directory file for simulator Iphone

后端 未结 8 1173
[愿得一人]
[愿得一人] 2021-01-30 03:25

i want to write a string in a file \"file.txt\": this file in my project (for Iphone) is inside Resources; I try to write a string in this file but it don\'t work, I show my cod

8条回答
  •  独厮守ぢ
    2021-01-30 03:58

    With the example code that you have here it will not write into your Resources folder, but into the Documents folder of the Simulator, which is actually where you should write on device, but as you mention that you only want to do this on the simulator, you could use

    filePath = [[NSBundle mainBundle] bundlePath] stringByAppendingPathComnponent:@"Resources"]
    

    But, don't do this in a shipping app, it will fail.

提交回复
热议问题