gpt4 book ai didi

ios - 将 RLMResults 转换为 RLMArray

转载 作者:IT王子 更新时间:2023-10-29 05:25:53 27 4
gpt4 key购买 nike

我正在使用 objectsWhere 查询 RLMArray,我得到了一个 RLMResults,但我需要一个 RLMArray,其结果在我的代码中。

private var data: RLMArray?

self.data = self.currentSubcategory!.datasheets // is a RLMArray
self.data = self.data!.objectsWhere("is_favourite = 1")

最佳答案

RLMArray has been split into two classes: RLMArray and RLMResults. RLMArray is now used only for to-many properties on RLMObject classes, while RLMResults is used for all of the querying and sorting methods. This was done to reflect that the two actually had fairly different APIs (for example, RLMResults does not have addObject:), and they’re expected to diverge further as we add change notifications for queries.

The migration for this should be as simple as replacing RLMArray with RLMResults in all of the places that the compiler complains about.

To go with this, arraySortedByProperty:ascending: has been renamed to sortedResultsUsingProperty:ascending:, and addObjectsFromArray: has been renamed to addObjects: to reflect the fact that you can pass any enumerable object to it (such as NSArray, RLMArray, or RLMResults).

来源:http://realm.io/news/realm-cocoa-0.87.0/#rlmresults

希望这就足够了

关于ios - 将 RLMResults 转换为 RLMArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27129566/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com