Re:Re: How to specify the file type to Audio file when dragging...?
Re:Re: How to specify the file type to Audio file when dragging...?
- Subject: Re:Re: How to specify the file type to Audio file when dragging...?
- From: Bright <email@hidden>
- Date: Tue, 19 May 2009 12:15:03 +0800 (CST)
>On May 18, 2009, at 9:28 PM, Bright wrote:
>
>> I am a novice of Cocoa. So can you tell me detailed about the
>> specify the file type to Audio File
>> when dragging a file to tableview?
>> I tried the "validateDrop method" and NSworkspace, but failed.
>
>
>That depends. Can you please post your code?
>
Hi ,this is my code,but the code can not limit the file to Audio file :
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op
{
? ? [tv setDropRow:[tv numberOfRows] dropOperation:NSTableViewDropAbove];
? ? returnNSTableViewDropAbove;
}
- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op
{?
? ? NSPasteboard *myPasteboard=[info draggingPasteboard];
//NSArray *typeArray=[NSSound soundUnfilteredTypes];
NSArray *typeArray=[NSArrayarrayWithObjects:NSFilenamesPboardType,nil];
? ? NSString *filePath,*availableType,*lastPathOfFileName;
? ? NSArray *filesList;
? ? int i;
? ? availableType=[myPasteboard availableTypeFromArray:typeArray];
? ? filesList=[myPasteboard propertyListForType:availableType];
? ? for (i=0;i<[filesList count];i++)
? ? {
? ? ? ? filePath=[filesList objectAtIndex:i];
lastPathOfFileName=[filePath lastPathComponent];
[songsFullPathinsertObject:filePath atIndex:row+i];
? ? ? ? [songsinsertObject:lastPathOfFileName atIndex:row+i];
? ? }
? ? [songTablereloadData];
? ? [songTableselectRow:row+i-1byExtendingSelection:NO];
returnYES;
}
thank you very much.
_______________________________________________
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