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

查看:167
本文介绍了将下载的文件存储在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?

/ strong>它必须支持苹果的新沙盒东西。

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的 App Sandbox设计指南,并阅读容器目录和文件系统访问。目录〜/ 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天全站免登陆