At the top of my UITableViewController
is the following:
let queue = DispatchQueue(label: \"background\")
When a task is dele
You could also use a ThreadSafe reference, a specific way to pass realm objects between threads:
let realm = try! Realm()
let person = Person(name: "Jane") // no primary key required
try! realm.write {
realm.add(person)
}
let personRef = ThreadSafeReference(to: person)
DispatchQueue(label: "com.example.myApp.bg").async {
let realm = try! Realm()
guard let person = realm.resolve(personRef) else {
return // person was deleted
}
try! realm.write {
person.name = "Jane Doe"
}
The steps provided by Realm Documentation: