I have an array of nsmanaged object class. And i want to sort the array using particular element.
every time i try to use it it gives me an error of Argument of '#keyPath' refers to non-'@objc' property 'questions' and Cannot convert value of type 'NSSortDescriptor' to expected element type 'ServiceQuestion'
[NSSortDescriptor(key: #keyPath(objectClassArray), ascending: true)]
let sortDescriptor = NSSortDescriptor(key: "last", ascending: true, selector: #selector(NSString.localizedStandardCompare))
Use particular element instead of "last" key
(people as NSArray).sortedArray(using: [sortDescriptor])
Hope this will help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.