• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I get a file reference w/o relying on the path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Brad Stone <email@hidden>
  • Date: Sun, 25 Apr 2010 11:53:57 -0400

SOLVED

This works just as it should.  For reasons that I thought were valid at the time (I no longer think so) I had this code in writeSafelyToURL: right after the writeTofile: command.  What was strange was the url was valid because I was storing the bookmark after the file was successfully written to the hard drive but I guess there wasn't enough information in the file yet to make a valid reference (bookmark).  I moved it farther down the line with the exact same code and everything worked fine.

Thank you for all your help.


On Apr 18, 2010, at 10:43 PM, Noah Desch wrote:

>
> Are you sure the data is being stored into your "note" dictionary correctly? Here is my bookmark resolution code, it looks almost exactly like yours. I'm running on 10.6.3 and building for 10.6 with GC off.
>
>
> - (NSURL *)resolveBookmarkData:(NSData *)bookmark withOptions:(NSURLBookmarkResolutionOptions)options needsUpdate:(BOOL *)stale
> {
> 	NSURL *url;
> 	NSError *error;
> 	NSMutableDictionary *userInfo;
>
> 	error = Nil;
> 	*stale = NO;
> 	url = [NSURL URLByResolvingBookmarkData:bookmark options:options relativeToURL:Nil bookmarkDataIsStale:stale error:&error];
> 	if ( url ) {
> 		return url;
> 	}
>
> 	if ( error && [[error domain] isEqualTo:NSCocoaErrorDomain] && [error code] == NSFileNoSuchFileError ) {
> 		// error presentation and resolution code follows...
>
>
>
>
> -Noah
>
>
>
> On Apr 18, 2010, at 10:08 PM, Brad Stone wrote:
>
>> The error comes back "file does not exist" and the NSLog statement shows "url = (null)" after I change the name of the file in the Finder.  If I change the file name back to what it was when the bookmark was saved the file opens fine.  I changed my creation option to 0.  No difference.
>>
>> NSData *bookmarkData = [note valueForKey:@"bookmarkData"];
>> 		NSError *error = nil;
>> 		BOOL isStale;
>> 		NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData options:0 relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
>> 		NSLog(@"url = %@", [url description]);
>>
>> 		if (error != nil) {
>> 			[NSApp presentError:error];
>> 		}
>>
>>
>> On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:
>>
>>>
>>> On Apr 18, 2010, at 10: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];
>>>
>
> _______________________________________________
>
> 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

_______________________________________________

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

References: 
 >How do I get a file reference w/o relying on the path? (From: Brad Stone <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Ken Thomases <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Brad Stone <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Noah Desch <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Brad Stone <email@hidden>)
 >Re: How do I get a file reference w/o relying on the path? (From: Noah Desch <email@hidden>)

  • Prev by Date: Re: NSApplicationMain question
  • Next by Date: Re: NSTableview background image for column?
  • Previous by thread: Re: How do I get a file reference w/o relying on the path?
  • Next by thread: Re: How do I get a file reference w/o relying on the path?
  • Index(es):
    • Date
    • Thread