在 Cocoa 中存储下载的文件 [英] Storing downloaded files in Cocoa

查看:25
本文介绍了在 Cocoa 中存储下载的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Cocoa 应用程序,它需要 10.7+.所以,我很乐意使用新的闪亮 API.

I am developing a Cocoa application, and it requires 10.7+. So, I will gladly use the new shiny APIs.

我想要做的是从我们的后端服务器下载一些 MP3 和可能的一些 XML 数据,并将其存储在用户的 Mac 上.我很想将它存储在application.app"目录中,以及与应用程序捆绑在一起的初始资源.

What I would like to do is download some MP3s and probably some XML data from our back-end server, and store it on the user's Mac. I would much like to store it within the "application.app" directory, alongside the initial resources that are bundled with the application.

我可以这样做吗?在 application.app 中存储文件?

Can I do that? Store files within the application.app?

如果没有,存储附加数据的首选目录在哪里?

If not, where is the preferred directory to store the additional data?

注意:它必须支持苹果的新沙盒工具.

NOTE: It must support apple's new sandboxing thingie.

(这是个好主意吗:参考)

// save our buddy list to the user's home directory/Library/Preferences.
    [prefs writeToFile:[@"~/Library/Preferences/MiniMessage Client.plist"
                    stringByExpandingTildeInPath] atomically: TRUE];

推荐答案

这是 Apple 的 应用沙盒设计指南 并阅读容器目录和文件系统访问".目录~/Library/Container/com.yourcompany.yourappname/"及其子目录将仅是您的应用程序,因此在我看来,该目录将是您保存将从网络下载的内容的最佳位置.

Here's Apple's App Sandbox Design Guide and read the "Container Directories and File System Access". The directory "~/Library/Container/com.yourcompany.yourappname/" and it's subdirectories will be your Apps only, so seems to me that that directory would be your best place of saving the things you'll be downloading from the web.

这篇关于在 Cocoa 中存储下载的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆