扩展元素{
git checkout -b <branch>
}
这里我想比较使用NSPredicate的pageId。我该怎么做? 我尝试了以下内容。
案例1:
@nonobjc public class func fetchRequest() -> NSFetchRequest<Element> {
return NSFetchRequest<Element>(entityName: "Element");
}
@NSManaged public var elementId: Int32
@NSManaged public var elementName: String?
@NSManaged public var elementText: String?
@NSManaged public var pageId: Int32
@NSManaged public var sortOrder: Int32
案例2:
elementFetch.predicate = NSPredicate(format: "pageId == %@","1")
var Data = try moc.fetch(elementFetch as! NSFetchRequest<NSFetchRequestResult>) as! [Element]
案例3:
elementFetch.predicate = NSPredicate(format: "pageId == %i",1)
var Data = try moc.fetch(elementFetch as! NSFetchRequest<NSFetchRequestResult>) as! [Element]
没有一个案例有效。我无法找到关于此谓词的任何文档,尤其是比较INT32
请帮忙
答案 0 :(得分:0)
字面值非常简单
elementFetch.predicate = NSPredicate(format: "pageId == 1")