@FetchRequest(
entity: UserInfo.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \UserInfo.name, ascending: true)
],
predicate: NSPredicate(format: "name == %@", "Lilei"))
) var userinfoes: FetchedResults<UserInfo>

NSPredicate

描述了一个过滤器,我们将使用它来决定显示哪些结果

NSPredicate(format: "name == %@", "LiLei")

NSSortDescriptor

告诉我们要在哪个字段上进行排序,以及我们要它递增还是递减

NSSortDescriptor(keyPath: \UserInfo.name, ascending: true)