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
Show parent comment
1
u/B8edbreth Jan 09 '24
So this sort of works for me
I put the file coordinator code around my readFromURL override in my NSDocument subclass.
Than if I call [[NSDocumentController sharedDocumentController]openDocumentWithContentsOfURL:retURL display:YES error:NULL]; it works but that method is deprecated.
So if I called one one I am supposed to
[[NSDocumentController sharedDocumentController]openDocumentWithContentsOfURL:retURL display:YES completionHandler:NULL];
the document come up but is locked. Obviously that isn't good.