I understand that the App Store requires most data to be stored and retrieved in the Application Support folder for an app. However, it seems that apps can also write to and read from the Preferences folder. Can anyone confirm this? Also, what other, if any, directories can be utilized in App Store apps without being rejected upon submission?
specialfolder.preferences will work in your app and is a nice place to store preferences.
If you prompt the user to save or load a file or folder, the user can select any folder.
I don’t trust my memory anymore, but it seems that I read on this Forum not long ago that attempting to write to SpecialFolder.Preferences in a sandboxed app with Mavericks will result in the dreaded I/O exception. Searching this Forum, IMHO, is completely unhelpful. Can anyone confirm that or tell me I’m bonkers?
You cannot directly write to SpecialFolder.Preferences using FolderItem methods with apps in the Mac App Store. If you use the Cocoa API for NSUserDefaults or CFPreferences, you can save stuff there. I believe MacOSLib has implemented that.
Thanks for the clarification, Paul.
Is there a definitive list of how to access files and folders in sandboxed apps somewhere (clearer than Apple’s and if possible geared to Xojo)? I see lots of conflicting and vague information.
For example: Can I drop a folder on a sandboxed icon and have that app be able to scan that folder and all its children? If I drop a file, can I scan the file’s containing folder contents? Bundles affect the behaviours in any way?
Most of my apps rely heavily in drag and drop and copy/past of finder items, which trigger folder scans (children of dropped folder or children of dropped file’s containing folder, usually). I am unclear on what works when. Especially if I then need to write other files and not the dropped ones.
I have seen that The Unarchiver, even though it open a file on double-click, is not able to write to that file’s containing folder. This is because although it can open the file it can’t write to the file’s containing folder.
This has always been recommended against, instead use NSUserDefaults or CFPreferences, if you want to manage your own prefs file format then it’s recommended to use the App Support folder.
Mavericks is the first release where Apple seems to actively start to alter the way preferences work. If you manually delete a file that is used by NSUserDefaults or CFPreferences, it causes complications for apps.