Storing downloaded files in Cocoa

霸气de小男生 提交于 2019-12-11 11:08:19

问题


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

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.

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.


(Is this a good idea: reference)

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

回答1:


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.



来源:https://stackoverflow.com/questions/10169223/storing-downloaded-files-in-cocoa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!