2

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.

Image

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?

Manthan
  • 3,856
  • 1
  • 27
  • 58
  • use [NSURL URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/#//apple_ref/occ/clm/NSURL/URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:) to read the data from scoped bookmark – Sega-Zero Jul 28 '15 at 18:45
  • Possible duplicate of [How to allow permission for user's Home folder in cocoa application for mac](https://stackoverflow.com/questions/31645372/how-to-allow-permission-for-users-home-folder-in-cocoa-application-for-mac) – Jon Schneider Jul 28 '19 at 19:47

0 Answers0