在 iPhone 沙箱中查找文件
在我的应用程序开始时,用户录制他们的声音,然后将其保存为沙箱中的“recorded.wav”。稍后如何创建一个指示其位置的字符串?我想要类似这样的内容:
/var/folders/u6/u6pKbm2MFriwajkdt-OQME+++TI/-Tmp-/recorded.wav
谢谢,
请记住这是针对 iPhone 设备和模拟器的。
At the beginning of my app the user records their voice which is then saved as 'recorded.wav' in the sandbox. How do I later create a string indicating it's location? I would like something that looks like:
/var/folders/u6/u6pKbm2MFriwajkdt-OQME+++TI/-Tmp-/recorded.wav
Thanks,
Keep in mind this is for the iPhone device and simulator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSHomeDirectory()
返回应用程序沙箱的路径。然后您可以访问其中的任何文件或目录。还有
NSTemporaryDirectory()
它返回特定于您的应用程序的临时文件夹的路径。请注意,在模拟器中运行应用程序时,NSTemporaryDirectory()
将返回系统范围的目录。如果您喜欢更通用的解决方案,请查找有关
NSSearchPathForDirectoriesInDomains()
函数的文档。NSHomeDirectory()
returns the path to your application's sandbox. You can then reach any file or directory within it.There is also
NSTemporaryDirectory()
which returns the path to the temp folder specific to your app. Do note, that when running your app in the Simulator,NSTemporaryDirectory()
will return a system-wide directory.If you like a more general solution, lookup the documentation on
NSSearchPathForDirectoriesInDomains()
function.您可以通过 NSSearchPathForDirectoriesInDomains 获取文件的路径 基础函数如下:
You can get the path to your file via the
NSSearchPathForDirectoriesInDomains
foundation function as such: