如果这是我的代码,为什么我在使用realm存取数据时会出现错误:Value of type 'RLMResults' has no member 'arraySortedByProperty'。
var items = [NSManagedObject]()
var todos: RLMResults {
get {
return ToDoItem.allObjects()
}
}
override func viewDidLoad() {
super.viewDidLoad()
title = "Todos"
}
func deleteRowAtIndexPath(indexPath: NSIndexPath)
{
let realm = RLMRealm.defaultRealm() //1
let objectToDelete = todos[UInt(indexPath.row)] as! ToDoItem //2
realm.beginWriteTransaction() //3
realm.deleteObject(objectToDelete) //4
realm.commitWriteTransaction() //5
todos = ToDoItem.allObjects().arraySortedByProperty("name", ascending: true) //6
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) //7
}