The Mac app I’m working on stores documents in iCloud Drive. Showing an SWCollaborationView
in the toolbar works when creating an NSItemProvider
using the document’s fileURL
like this:
if let documentURL = document.fileURL {
toolbarItem.view = SWCollaborationView(itemProvider: NSItemProvider(object: documentURL))
}
This only works if a document was previously saved to disk and is then opened, though, because a new, unsaved document doesn’t have a fileURL
yet. So this means I can’t show an SWCollaborationView
for unsaved documents. What I don’t quite understand is what we are supposed to do in this situation.
The current version of Pages (which doesn’t use SWCollaborationView
yet, of course) seems to show a button for collaboration for new documents and when you click that, the document is saved to iCloud without user interaction before the popover opens. How would I go about doing this in my app?
And here’s also a bonus question: Do I have to handle renaming/moving of the document manually? That is, does SWCollaborationView
automatically handle the case where the document is renamed in Finder/Files? I’m curious because the SWCollaborationView
references an NSItemProvider
which in turn references an NSURL
and it’s not clear to me if that should work. And if I have to do it manually: Does this mean I’ll have to create a new SWCollaborationView
and set it on my toolbar item?