我有一个实体类别,可以包含相同类型的子类别,所以我只希望那些具有多个子类别的类别可用。
这是我的代码,以获取详细信息。
fixtures %w[user groups memberships]
这是我遇到的错误。
func getAllCategory() -> [TestCategory] {
let fetchRequest = NSFetchRequest<Category>(entityName: "\(Category.self)")
fetchRequest.includesSubentities = true
fetchRequest.predicate = NSPredicate.init(format: "%K.count > %i","childCategories",0)
do {
let results = try self.getCurrentContext().fetch(fetchRequest)
} catch {
}
}
谢谢
答案 0 :(得分:0)
我不确定,但似乎您一次对很多关系。看来您的childCategories具有多个父类别。我以前有那个问题。设置关系分别。目的地并重新构建(让Xcode创建必要的文件)对我有所帮助。