在 Xcode 8.2.1 中为 iOS 应用程序使用 swift 3。
我知道在新线程上分派一些处理时我需要一个 autoreleasepool 块。但是在主线程上调度回时是否需要它?
假设我们在主线程上并执行以下操作:
DispatchQueue.global(qos: .background).async {
autoreleasepool {
//***** do something in the background
} // autoreleasepool
DispatchQueue.main.async {
//***** do something on the main thread when background job is done
//***** does this something need to be enclosed in an autoreleasepool block ?
} // DispatchQueue.main.async
} // DispatchQueue.global
Run Code Online (Sandbox Code Playgroud)