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

getResourceValue:forKey:error: Unrecognized Selector


  • Subject: getResourceValue:forKey:error: Unrecognized Selector
  • From: GW Rodriguez <email@hidden>
  • Date: Wed, 26 Oct 2011 20:20:55 -0700 (PDT)

I am trying to limit files with certain UTI's from dropping into a table view.  Here's my code so far:



// in the init method I set the registerForDraggedTypes with NSURLPboardType

-(NSDragOperation) tableView: (NSTableView*)tv 
                validateDrop: (id <NSDraggingInfo>)info 
                 proposedRow: (int)row 
       proposedDropOperation: (NSTableViewDropOperation)op 
{    

    NSDragOperationdragOp = NSDragOperationCopy;
    
    // if drag source is self its a move unless the option key is pressed
    if ([info draggingSource] == playlistView) {
        NSEvent *currentEvent = [NSApp currentEvent];
        int optionKey = [currentEvent modifierFlags] & NSAlternateKeyMask;
        
        if (optionKey == 0) dragOp = NSDragOperationMove; // option not pressed
        return dragOp;
    }
    
    // if drag source is not self then... OUTSIDE FILE BEING DRAGGED IN
    NSArray*firstType = [NSArrayarrayWithObjects:NSURLPboardType, nil];
    
    if([[[info draggingPasteboard] types] containsObject:NSURLPboardType] ) {
        NSString *availableType = [[info draggingPasteboard] availableTypeFromArray:firstType];
        NSString *fileType;
        NSURL *url;
        NSArray *filesList = [[info draggingPasteboard] propertyListForType:availableType];
        
        for (int i=0; i<[filesList count]; ++i) {
            url = [filesList objectAtIndex:i];
            
            if ([url getResourceValue:&fileType forKey:NSURLTypeIdentifierKey error:NULL]) {
                NSLog(@"%@", fileType); // just print the type for now
            }
        }
    }
    
    [tv setDropRow:row dropOperation:NSTableViewDropAbove];    
    return dragOp;
}



So as I'm sure you've noticed, I'm not changing the dragOp for an outside file being dragged in.  For some reason I keep getting an unrecognized selector error with the getResourceValue:forKey:error: method.  I'm completely stumped, any help would be greatly appreciated. 

GW
_______________________________________________

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: getResourceValue:forKey:error: Unrecognized Selector
      • From: Ken Thomases <email@hidden>
    • Re: getResourceValue:forKey:error: Unrecognized Selector
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Core Animation + Focus Ring
  • Next by Date: Re: Custom NSView drawing
  • Previous by thread: Re: Core Animation + Focus Ring
  • Next by thread: Re: getResourceValue:forKey:error: Unrecognized Selector
  • Index(es):
    • Date
    • Thread