Reputation: 2472
I have code in swift (realm v0.88.0), for other model its works but only for this type I get this bug
var result = Type.objectsInRealm(RLMRealm.defaultRealm(), withPredicate: NSPredicate(format: "id == %i",0)) as RLMResults
println("result \(result)------- count \(result.count), obj \(result.firstObject())")
And print result
result RLMResults <0x16525400> (
[0] Type {
id = 0;
msg = Vacation;
},
[1] Type {
id = 0;
msg = Vacation;
}
)------- count 2, obj
I cannot get lastobject(), objectAtIndex(0), [0] all return nil
As for me its some bug in realm, but maybe somebody was met same problem and successful resolved it
Upvotes: 0
Views: 913
Reputation: 14409
This should work:
let results = Type.objectsWhere("id == 0")
println("first object: \(results[0])")
// or
println("first object: \(results.objectAtIndex(0))")
If it doesn't work for you, please create an issue with enough information for us to reproduce at https://github.com/realm/realm-cocoa/issues
Upvotes: 2