func fetchCD() -> [Entity] {
var options : [Entity] = []
let fetchRequest = NSFetchRequest(entityName:"EntityName")
do {
options = try cdh.managedObjectContext.executeFetchRequest(fetchRequest) as! [Entity]
} catch let error as NSError {
print("Fetch failed: \(error.localizedDescription)")
} catch {
}
//here I'd like to order by Entity.types.counter (desc)
return options
}
//Entity+CoreDataProperties.swift
extension Entity {
//my values
@NSManaged var types: NSSet?
}
//Type+CoreDataProperties.swift
extension Type {
@NSManaged var counter: NSNumber
}
如何通過conter對我的[Entity]數組進行排序,它是Type實體(與實體有很多關係)的屬性?快速排序有很多關係的實體數組
謝謝,我得到:'NSSet類型的價值?沒有會員'櫃檯' –
你如何獲得櫃檯的價值?只是在塊中修改,它應該工作 – UlyssesR