There are tow realm
object class one is Entry
and other is Work
. The model scenario is looks like below.the Entry
class is
open class Entry: Object {
dynamic open var date = Entry.defaultDate()
dynamic open var quantity = 0.0
dynamic open var percentage = 0.0
dynamic open var goal = 0.0
open let gulps = List<Work>()
}
And the Work
class looks like this.
open class Work: Object {
dynamic var quantity = 0.0
dynamic var type = 0
}
after inserting some data one Entry
object looks like this.
(Entry {
date = 2017-11-29;
quantity = 1.193675890564919;
percentage = 59.68379452824593;
goal = 2;
gulps = RLMArray <0x6040000e7800> (
[0] Work {
quantity = 0.5;
type = 0;
},
[1] Work {
quantity = 0.5;
type = 1;
},
[2] Work {
quantity = 0.09683794528245926;
type = 0;
},
[3] Work {
quantity = 0.09683794528245926;
type = 2;
}
);
})
Now I am trying to make an array which contain the total quantity according to Work
types where the array index is according to Work
type.So the array for this entry should be.
[0.59683,0.5,0.09683794528245926]
So How can I generate this array in efficient way?