I'm trying to create a MutableProperty
which holds a Results
received from Realm.objects(_:)
.
To create the property I need to give it an initial value; hence an 'empty' Results
.
I've tried creating one using:
var someThings = Results<SomeObject>()
MutableProperty(someThings)
But the compiler gives me the error: Cannot invoke initializer for type 'Results<SomeObject>' with no arguments
.
While I understand the error, I'm not really sure how to create a Results
object in this context.
Looking at the source of Results
I couldn't find an init
either.
So my question is; how can I create a Results
myself to use in a MutableProperty
?
Edit:
I've seen this question...but that doesn't really help (unless I'm going to create a "wrapper" for the MutableProperty or something).
With help of the comments on my OP; I created a mutable property with an empty set of results by fetching objects with an 'invalid' filter.
E.g. MutableProperty(realm.objects(SomeObject.self).filer("EMPTY SET"))
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With