0
我試圖使用RealmGridController來顯示關係列表中的元素。我有一個對象Collection
擁有的Items
列表:列表成員列表中的領域謂詞
class Collection: Object {
let items = List<Item>()
dynamic var name: String?
}
class Item: Object {
dynamic var name: String?
}
我想用一個RealmGridController顯示所有的項目在一個特定的collection
的items
財產。 RealmGridController使用RBQFetchedResultsController來管理其數據加載,並且提取的結果控制器使用實體名稱和謂詞來獲取要顯示的項目列表。
如何將關係List
中的項目列表表示爲實體名稱和謂詞?
有幾件事情我已經試過了都沒有奏效:
entityName = Item.className()
// 'Invalid predicate', reason: 'Predicate with IN operator must compare a KeyPath with an aggregate'
basePredicate = NSPredicate(format: "SELF in %@.items", collection)
// Same
basePredicate = NSPredicate(format: "SELF in %@", collection.items)
// 'Invalid predicate', reason: 'Predicate with ANY modifier must compare a KeyPath with RLMArray with a value'
basePredicate = NSPredicate(format: "ANY SELF in %@", collection.items)
這似乎是顯示領域List<>
爲獲取結果控制器的內容應該是相當簡單,但我做不到似乎弄明白了。謝謝!