• 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
NSURL bookmark error return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURL bookmark error return


  • Subject: NSURL bookmark error return
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 18 Dec 2012 00:37:02 -0800

Was there a thread recently that listed a couple of Cocoa frameworks methods that mis-handle the NSError** parameter? What were those methods? The reason I ask is that the general file system documentation for dealing with bookmarks:

> https://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/AccessingFilesandDirectories/AccessingFilesandDirectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW10


gives this code fragment:

> - (NSData*)bookmarkForURL:(NSURL*)url {
>     NSError* theError = nil;
>     NSData* bookmark = [url bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile
>                                             includingResourceValuesForKeys:nil
>                                             relativeToURL:nil
>                                             error:&theError];
>     if (theError || (bookmark == nil)) {
>         // Handle any errors.
>         return nil;
>     }
>     return bookmark;
> }

which doesn't follow the rules for testing for errors. The succeeding fragment is even worse:

> - (NSURL*)urlForBookmark:(NSData*)bookmark {
>     BOOL bookmarkIsStale = NO;
>     NSError* theError = nil;
>     NSURL* bookmarkURL = [NSURL URLByResolvingBookmarkData:bookmark
>                                             options:NSURLBookmarkResolutionWithoutUI
>                                             relativeToURL:nil
>                                             bookmarkDataIsStale:&bookmarkIsStale
>                                             error:&theError];
>
>     if (bookmarkIsStale || (theError != nil)) {
>         // Handle any errors
>         return nil;
>     }
>     return bookmarkURL;
> }

since it doesn't even check the returned value.

Is this a documentation error, or is the documentation explaining how to code around a frameworks deficiency?

BTW the NSURL class reference documentation doesn't say anything about this. It doesn't even mention nil return values.




_______________________________________________

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

  • Follow-Ups:
    • Re: NSURL bookmark error return
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: NSView mouseMoved problem
  • Next by Date: Re: NSView mouseMoved problem
  • Previous by thread: Re: NSView mouseMoved problem
  • Next by thread: Re: NSURL bookmark error return
  • Index(es):
    • Date
    • Thread