如何在核心数据swift4中获取最后一行

时间:2018-04-03 11:03:07

标签: core-data swift3

我正在尝试获取最新插入的行

这是我写的代码

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

但它不会检索最后插入的行。我错过了什么?

0 个答案:

没有答案