• 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
How to limit the file type when dragging?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to limit the file type when dragging?


  • Subject: How to limit the file type when dragging?
  • From: Bright <email@hidden>
  • Date: Wed, 13 May 2009 14:59:54 +0800 (CST)

Hi all

     Now, I want to drag and drop sound files(such as mp3) into a tableview to implement the sound-files' playing.
But  how limit the file type to sound file only available when drag and drop files into tableview?
my code is :

- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op

{

    NSPasteboard *myPasteboard=[info draggingPasteboard];

    NSArray *typeArray=[NSArray arrayWithObjects:NSFilenamesPboardType,nil];

    NSString *filePath,*availableType;

    NSArray *filesList;

    int i;

    availableType=[myPasteboard availableTypeFromArray:typeArray];

    filesList=[myPasteboard propertyListForType:availableType];




    for (i=0;i<[filesList count];i++)

    {

        filePath=[filesList objectAtIndex:i];

        [songs insertObject:filePath atIndex:row+i];

    }

    [songTable reloadData];

    [songTable selectRow:row+i-1 byExtendingSelection:NO];

    return YES;

}



Thank you
Bright

_______________________________________________

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: How to limit the file type when dragging?
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Desktop window eating clicks
  • Next by Date: Win->MacOS porting question.
  • Previous by thread: Re: Desktop window eating clicks
  • Next by thread: Re: How to limit the file type when dragging?
  • Index(es):
    • Date
    • Thread