Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm: How to add two Results<(Object)> in Realm

Tags:

ios

swift

realm

For arrays we could just do

resultArray = array1 + array2

I have two results of Results<(Object)> how do I add them?

Do I have to loop or is there in any other way?

like image 211
Imran Avatar asked Jun 20 '15 06:06

Imran


1 Answers

RLMResults are like array but not array, so you cannot add them directly, you have to use predicates to get your results. This is mentioned in Realm Doc

RLMResults is an auto-updating container type in Realm returned from object queries.

RLMResults can be queried with the same predicates as RLMObject and RLMArray and you can chain queries to further filter query results.

RLMResults cannot be created directly.

But If you want to add objects of RLMArray or RLMResults in an existing RLMArray you can use – addObjects: method of RLMArray only condition is that both the results should be of the same class. RLMArray Doc for reference.

like image 104
Pradeep Singh Avatar answered Sep 27 '22 20:09

Pradeep Singh