我正试图阻止&放弃使用NSTableViews
的两个NSArrayControllers
之间的工作,而NSTableViewDataSource
又使用核心数据。我找到了一个解决方案,用基本数组和我的基本拖动和放大器来解释拖放。两个表之间的丢弃功能有效但我需要弄清楚如何将数据从源AC移动到目标AC,特别是在核心数据方面。
目标表的// MARK: - NSTableViewDataSource
extension TargetTableViewController : NSTableViewDataSource
{
func tableView(aTableView:NSTableView, validateDrop info:NSDraggingInfo, proposedRow row:Int, proposedDropOperation operation:NSTableViewDropOperation) -> NSDragOperation
{
if (operation == .Above)
{
return .Move;
}
return .Every;
}
func tableView(tableView:NSTableView, acceptDrop info:NSDraggingInfo, row:Int, dropOperation:NSTableViewDropOperation) -> Bool
{
var data:NSData = info.draggingPasteboard().dataForType(NSStringPboardType)!;
var rowIndexes:NSIndexSet = NSKeyedUnarchiver.unarchiveObjectWithData(data) as! NSIndexSet;
if ((info.draggingSource() as? NSTableView == sourceTableView) && (tableView == targetTableView))
{
//var value:String = sourceDataArray[rowIndexes.firstIndex];
//sourceDataArray.removeAtIndex(rowIndexes.firstIndex);
//targetDataArray.append(value);
sourceTableView!.reloadData();
targetTableView.reloadData();
return true;
}
else
{
return false;
}
}
}
方法如下:
@Url.Action("Index","Home",new{area="AccessControl"})
显然,我需要从源AC获取所选数据并将其移动到目标AC中,但我不知道如何为Core Data托管对象执行此操作。有人有解决方案吗?