• 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: getResourceValue:forKey:error: Unrecognized Selector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getResourceValue:forKey:error: Unrecognized Selector


  • Subject: Re: getResourceValue:forKey:error: Unrecognized Selector
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 28 Oct 2011 22:59:33 -0700

On Oct 26, 2011, at 8:20 PM, GW Rodriguez <email@hidden> wrote:

>     if([[[info draggingPasteboard] types] containsObject:NSURLPboardType] ) {
>         NSString *availableType = [[info draggingPasteboard] availableTypeFromArray:firstType];
>         NSString *fileType;
>         NSURL *url;
>         NSArray *filesList = [[info draggingPasteboard] propertyListForType:availableType];

NSURL is not a property list type. You should use the new NSPasteboardReading API (available since 10.6), or if you need backwards compatibility with 10.5, use +[NSURL URLFromPasteboard:] declared in <AppKit/NSPasteboard.h>.

>
>         for (int i=0; i<[filesList count]; ++i) {
>             url = [filesList objectAtIndex:i];
>
>             if ([url getResourceValue:&fileType forKey:NSURLTypeIdentifierKey error:NULL]) {

This will fail silently (fileType==nil, error==NULL) if the URL is not a file:// URL to an existing file on disk. -getResourceValue:forKey:error:, when given one of the file system resource keys, is really just a wrapper around other APIs like -[NSWorkspace typeOfFile:error:]. If someone has put an http:// URL on the pasteboard, you need to be ready to handle it.

--Kyle Sluder_______________________________________________

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: 
 >getResourceValue:forKey:error: Unrecognized Selector (From: GW Rodriguez <email@hidden>)

  • Prev by Date: Re: CAShapeLayer as a mask for CALayer: rounded corners are stretched
  • Next by Date: Re: Core Animation + Focus Ring
  • Previous by thread: getResourceValue:forKey:error: Unrecognized Selector
  • Next by thread: Re: getResourceValue:forKey:error: Unrecognized Selector
  • Index(es):
    • Date
    • Thread