The following code is from a NSTableViewDataSource
where I'm trying to impliement drag and drop.
Can someone tell me why the setString:forTypes:
method in the following code returns NO
under Leopard? It works fine in Snow Leopard. I checked the "Pasteboard Programming Topics for Cocoa" legacy document but I can't figure out what I'm doing wrong.
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSString *str;
if ([tableView isEqualTo:databaseView]) {
str = [[commander databases] objectAtIndex:[rowIndexes firstIndex]];
} else if ([tableView isEqualTo:favouritesView]) {
str = [[commander favourites] objectAtIndex:[rowIndexes firstIndex]];
}
if (str != nil) {
NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
[pboard declareTypes:types owner:nil];
if ([pboard setString:str forType:NSStringPboardType]) {
return YES;
} else {
[self handleErrorString:[NSString stringWithFormat:@"Error: Couldn't copy '%@' to pasteboard!", str]];
}
}
return NO;
}