iOS 写入文件
如果设备已越狱,文件系统将被解锁并打开供您查看和修改。如果我想编写一个将文件写入 /private/var/mobile/Library/Preferences/ 文件夹的应用程序,我是否必须使用 [fileManager copyItemAtURL:fileTempPathURL toURL:filePathURL error:NULL] 以外的命令; ?我正在使用这个命令,但它不起作用...感谢您的帮助!
If a device is jailbroken, the file system is unlocked and open for you to see and modify. If I wanted to write an app that wrote a file to the /private/var/mobile/Library/Preferences/ folder, do I have to use a command other than [fileManager copyItemAtURL:fileTempPathURL toURL:filePathURL error:NULL];
? I'm using this command, but it is not working... Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
如果您使用的是越狱设备,则可以写入系统中的任何位置。您可以通过多种不同的方式来完成此操作,从 C
FILE
指针到各种 iOS Foundation 方法,就像您在问题中提到的那样。您唯一需要注意的是,您的应用程序必须安装在
/Applications
目录中,而不是安装在~/Applications
目录中,iTunes 和 Xcode 会这样做默认执行。只有将它们与 MobileSafari、MobileMusicPlayer 等 Apple 基础应用程序一起放入该文件夹中,您的应用程序才会以这些 root 权限从跳板启动。您可以通过 SSH 将其放入/Applications
文件夹中。如果您没有像普通 App Store 应用程序一样手动将应用程序放入根应用程序文件夹中,并且您的应用程序驻留在
~/Applications
中自己的子文件夹中,则您的应用程序将在沙箱中启动。然后,该沙箱将阻止您访问应用程序沙箱之外的任何文件。If you're on a jailbroken device, you can write to any place in the system. You can do this in many different ways, from the C
FILE
pointer to all kinds of iOS Foundation methods, like the one you mentioned in your question.The only thing you'll have to mind is that your application has to be installed in the
/Applications
directory and not in the~/Applications
directory, what iTunes and Xcode will do by default. Only by putting them in that folder, along with the Apple base applications like MobileSafari, MobileMusicPlayer, etc. your app will launch from the springboard with those root privileges. You can put it in the/Applications
folder through SSH.If you do not manually put your app in the root application folder and your app resides in its own subfolder in
~/Applications
like normal App Store applications do, your app will launch in a sandbox. This sandbox will then prevent you from accessing any file outside your application's sandbox.