Arrays Swift 5-尝试添加阻力和阻力;Drop可对我的tableView重新排序,但在使用tableView moveRowAt函数时出错

Arrays Swift 5-尝试添加阻力和阻力;Drop可对我的tableView重新排序,但在使用tableView moveRowAt函数时出错,arrays,swift,drag-and-drop,Arrays,Swift,Drag And Drop,使用通用字符串数组在tableView中使用此函数执行拖放时,我没有问题: override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { categories.swapAt(sourceIndexPath.row, destinationIndexPath.row) tableView.reloadD

使用通用字符串数组在tableView中使用此函数执行拖放时,我没有问题:

override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
  categories.swapAt(sourceIndexPath.row, destinationIndexPath.row)
  tableView.reloadData()
}
但是,当我使用以下Category类所描述的数组“categories”时,我得到一个错误: “Results”类型的值没有成员“swapAt”。 此类是“items”子类的父类。这两类课程如下:

class Category: Object { 
  @objc dynamic var name: String = ""
  @objc dynamic var color: String = ""
  let items = List<Item>() //This is a Realm DB requirement
} 

class Item: Object {
  @objc dynamic var title: String = ""
  @objc dynamic var done: Bool = false
  @objc dynamic var dateCreated: Date?
  @objc dynamic var dueDate: Date?
  @objc dynamic var priority: String?
  var parentCategory = LinkingObjects(fromType: Category.self, property: "items") 
//The line above is a Realm DB requirement
}
类类别:对象{
@objc动态变量名称:String=“”
@objc动态变量颜色:String=“”
let items=List()//这是领域数据库要求
} 
类项:对象{
@objc动态变量标题:String=“”
@objc动态变量完成:Bool=false
@objc动态变量dateCreated:日期?
@objc动态var dueDate:日期?
@objc动态变量优先级:字符串?
var parentCategory=LinkingObjects(fromType:Category.self,属性:“items”)
//上面的行是领域数据库要求
}
上面的两个类都以realmdb所需的链接对象结束。 为了能够使用“.swapAt”函数将拖动的项目移动到其新位置,我可以进行哪些更改


应用程序中的其他一切都很好。提前谢谢

什么是类别?
让领域=试试!Realm()var categories:Results?
categories是一个字符串数组,其中包含我试图在其上实现拖放的tableViewController中显示的数据。它被键入为结果,以符合链接父/子对象的领域数据库。类别是父类别。