How to limit the file type when dragging?
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