Answers for "swift realm predicates"

1

predicate realm bool swift

import RealmSwift

class User: Object {
    dynamic var isRegistered = true
}

let realm = Realm()
realm.write {
    realm.add(User())
}
let p1 = NSPredicate(format: "isRegistered == YES")
let p2 = NSPredicate(format: "isRegistered == true")
let p3 = NSPredicate(format: "isRegistered == %@", NSNumber(bool: true))
let p4 = NSPredicate(format: "isRegistered = YES")
let p5 = NSPredicate(format: "isRegistered = true")
let p6 = NSPredicate(format: "isRegistered = %@", NSNumber(bool: true))
for predicate in [p1, p2, p3, p4, p5, p6] {
    println("users matching \(predicate): \(realm.objects(User).filter(predicate))")
}
Posted by: Guest on July-31-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language