我正在尝试获取最新插入的行
这是我写的代码
p
我也写过let context = coreData.getContext()
let request:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest() request.entity = NSEntityDescription.entity(forEntityName: "Days", in: context)
let sort = NSSortDescriptor(key: "day_id", ascending: false)
request.sortDescriptors = [sort]
request.fetchLimit = 1
并获取行
ascending:false
但它不会检索最后插入的行。我错过了什么?