I am having a cocoa mac app in which I want to ask for user's permission using NSOpenPanel.
In my app, I am deleting some data from downloads folder, application caches and mail downloads.
When I submitted my app, app got rejected with the below reason.
The app only finds files in the ~/Downloads folder. It would be appropriate to have the user grant access to the Home folder.
So, for that I used NSOpenPanel asking for access from user.
I am able to open dialogue box with NSOpenPanel.
Now, I am not aware of what should I do on allow button.
What is the meaning of that?
I have enabled my app sand boxing mode ON for app store distribution.
Please guide me on this...
EDIT
I have come to know that I'll have to use Security Scope Bookmark for this.
So In my projname.entitlements file, I added a key com.apple.security.files.bookmarks.app-scope
and set its Boolean value to YES
.
Now I did the below code to save...
NSURL* url = [panel URL];
NSData* data = [url bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:nil];
NSLog(@"%@",data);
if (data)
{
NSUserDefaults* prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:data forKey:@"ExportDirectory"];
[prefs synchronize];
}
Now, how to access this data when I launch my app again?