且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

writeToFile在sim中工作,但不在设备上工作

更新时间:2022-12-15 10:17:43

您无法写入应用包,由于沙箱的限制(这也会破坏您的代码签名)。您应该改为写入应用程序的documents目录。

You cannot write into your app bundle, because of sandbox restrictions (it would also break your code signature). You should write to your app's documents directory instead.

您可以使用以下命令获取Documents目录:

You can get your Documents directory with:

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