I am using the new NSURL bookmark data API introduced in OS X 10.6 to
store an "alias" to a file system resource. When I use

+[NSURL 
URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:]

to resolve the bookmark data, I get nil if the file no longer exists
(or has been moved to a different volume, etc.). Since I am not
passing NSURLBookmarkResolutionWithoutUI in the bookmark resolution
options, I expected to get a dialog, like that shown by the Finder
when you open an alias file that no longer resolves (i.e. a dialog to
cancel, fix the alias, etc...).

Is there a way to have NSURL automatically prompt to reconnect/resolve
the broken bookmark data?

The bookmark data is created via:

NSError *err
NSData *bookmarkData = [myFileURL
bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile
                                              includingResourceValuesForKeys:nil

   relativeToURL:nil

                error:&err];

though I get the same outcome if I use 0 for the options instead of
NSURLBookmarkCreationSuitableForBookmarkFile.

I attempt to resolve the same bookmarkData via:

BOOL stale;
NSError *err
NSURL *resolvedURL = [NSURL URLByResolvingBookmarkData:bookmarkData

             options:0

   relativeToURL:nil

bookmarkDataIsStale:&stale

                 error:&err];

Going through the dance of writing the bookmark data to a finder alias
file and then resolving the URL by reading bookmark data from that
file followed by the above method does not produce the desired UI
result either (though opening the alias file in the Finder does
produce the desired UI dialog).

Thanks,
Barry
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to