This is a problem that's been discussed on the dev forums since the early days 
of security-scoped bookmarks. How about implement -writeToURL:… so that if the 
document doesn't have a URL yet, you first create a placeholder file, before 
overwriting it with the real data? As I understand it, the important thing for 
bookmarks to work is to attach some metadata to the document, identifying it.

On 14 Aug 2013, at 23:00, Tom Harrington <[email protected]> wrote:

> I'm trying to create document scoped security URL bookmarks, for a document
> format that needs to refer to other documents. But it seems like the first
> time I save a document, there's a catch-22 in creating the bookmarks.
> 
> Creating a document scoped bookmark requires my document's URL as one of
> the arguments.
> 
> If I implement dataOfType:error:, I can't create a document-scope bookmark
> in my NSDocument subclass because [self fileURL] is nil. I end up creating
> an app-scoped bookmark instead, though it's not what I want.
> 
> If I implement writeToURL:ofType:error:, I get a URL for my document as the
> first argument. But, I still can't create the bookmark because my document
> doesn't exist yet. I get an error reading 'The file “[name]” couldn’t be
> opened because there is no such file'.
> 
> So, when am I supposed to create these bookmarks? Do I need to have the
> user save an empty document first just so I can create these bookmarks the
> next time around?
> 
> -- 
> Tom Harrington
> [email protected]
> AIM: atomicbird1
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/mabdullah%40karelia.com
> 
> This email sent to [email protected]


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to