For Realm Swift, could I use DispatchQueue with autorelease frequency of .workItem instead of autoreleasepool?

杀马特。学长 韩版系。学妹 提交于 2019-12-24 00:20:38

问题


From the doc we should be using:

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, that usage seems exactly how the following does:

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
    }
}

Could someone confirm the second approach works as expected?

来源:https://stackoverflow.com/questions/49459967/for-realm-swift-could-i-use-dispatchqueue-with-autorelease-frequency-of-workit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!