For Realm Swift, can I use DispatchQueue with auto-rehabilitation frequency .workItem instead of autoreleasepool?

From the document, we should use:

DispatchQueue(label: "background").async { autoreleasepool { let realm = try! Realm() let theDog = realm.objects(Dog.self).filter("age == 1").first try! realm.write { theDog!.age = 3 } } } 

However, this usage is similar to how it is done:

 DispatchQueue(label: "background", autoreleaseFrequency: .workItem).async { let realm = try! Realm() let theDog = realm.objects(Dog.self).filter("age == 1").first try! realm.write { theDog!.age = 3 } } 

Can anyone confirm that the second approach works as expected?

+1
source share

Source: https://habr.com/ru/post/1013280/


All Articles