Re: How do I get a file reference w/o relying on the path?
Re: How do I get a file reference w/o relying on the path?
- Subject: Re: How do I get a file reference w/o relying on the path?
- From: Charles Srstka <email@hidden>
- Date: Sun, 18 Apr 2010 21:43:01 -0500
On Apr 18, 2010, at 9:43 AM, Brad Stone wrote:
> I'm storing the bookmark data in an array displayed in a table:
> NSData *bookmarkData = [inAbsoluteURL bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile
> includingResourceValuesForKeys:nil
> relativeToURL:nil
> error:&error];
>
>
>
>
> When the user double clicks on the row in the table I want to open the file. I use this:
> NSError *error;
> BOOL isStale;
> NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
>
> When the file's name or directory changes on my hard drive the resolved url == nil. I'd like it to resolve to the actual file even if my app is closed and opened again (I'm saving the bookmarkData to repopulate the table the next time the user opens my app). I thought that's what bookmarks did in 10.6 - I could be wrong. An ugly workaround would be when the user double-clicks for me to create an actual alias file in a temp folder from the bookmark data and store that in my array, recreate it in a temp folder and launch that. I'm sure that's wrong - there has got to be a better way.
Hmm... have you tried converting the URL to a file reference URL first via its -fileReferenceURL method, and then generating a bookmark from that?
Charles_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden