>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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to