Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: getResourceValue:forKey:error: Unrecognized Selector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getResourceValue:forKey:error: Unrecognized Selector



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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.