Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert RLMResults to RLMArray

Tags:

ios

swift

realm

I am querying over a RLMArray with objectsWhere and i get a RLMResults, but i need a RLMArray with the results a this point in my code.

private var data: RLMArray?

self.data = self.currentSubcategory!.datasheets // is a RLMArray
self.data = self.data!.objectsWhere("is_favourite = 1")
like image 806
Marcel Avatar asked Nov 25 '14 14:11

Marcel


Video Answer


1 Answers

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).

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

Hope that's enough

like image 58
Vi Matviichuk Avatar answered Oct 21 '22 01:10

Vi Matviichuk