Search code examples
objective-ccocoafilesystemsnsfilemanagernsworkspace

Why Should I Save URL's Bookmark Data To The Preferences


Hey friends I came up with the question today that I have a window where I am adding users selected folder in my app from NSOpenSavePanel. I was accessing all the files and folders properly but as soon as I quit my app I am not able to open those folder because when I am giving path to open those files or folders it is showing pop up You don't have permission to access this folder

I saved BookMark data to my app's preferences and now it is working fine.

The question was ; What exactly is happening ?

Looking forward to you.


Solution

  • The reason for this is the App Sandbox. The idea is that the user controls to what files an app has access.

    For a one time access everything is handled for you. But if you want keep access across launches of your app you need to store and restore a bookmark.

    You find all details about this in: Security-Scoped Bookmarks and Persistent Resource Access