Reputation: 3641
I have an NSArrayController that I'm using to provide data to an IKImageBrowserView. I want to support drag and drop from the IKImageBrowserView to other applications. Here's the relevant method from my code:
- (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard *)pasteboard{
NSArray *items = [[resultsArrayController arrangedObjects] objectsAtIndexes:itemIndexes];
if(![pasteboard writeObjects:items]){
return 0;
}
return [items count];
}
My app is new so I'm targeting 10.6+ and according to the documentation, "On Mac OS X v10.6 and later, use writeObjects: to write URLs directly to the pasteboard instead."
I've verified that the objects that I am attempting to write are indeed NSURL objects, so I'm not sure where the process is breaking down or how to further troubleshoot the problem. Thanks in advance for any help.
Upvotes: 3
Views: 1566
Reputation: 96333
Have you cleared the pasteboard yet? You need to do that, and thereby become the pasteboard's owner, before you can write objects to the pasteboard.
Upvotes: 15
Reputation: 2746
Are the objects that are to be sent to -[NSPasteboard writeObjects:] supposed to be NSPasteboadItems? You can set their string value to the absoluteString of the NSURL and write an array of NSPasteboadItems.
Upvotes: -1