r/macosprogramming • u/B8edbreth • Jan 09 '24
Custom Recent Documents
I'm woking on a document based app. I've created a starting window similar to Xcode recent items window when the app first starts. If I turn off sandboxing then I have no trouble opening files from the tableview using :[[NSDocumentController sharedDocumentController]openDocumentWithContentsOfURL:retString display:YES completionHandler:nil];
With sandboxing on I can't access the file. Is there a way with sandboxing on to open a file without the user specifying it through an NSOpenPanel?
2
Upvotes
View all comments
3
u/gybemeister Jan 09 '24
You need to use Bookmarks. What I do is I create a bookmark when I open the file using the NSOpenPanel and save it in the UserDefaults and then use it when you open the file directly.