extension DispatchQueue {
private static var token: DispatchSpecificKey<()> = {
let key = DispatchSpecificKey<()>()
DispatchQueue.main.setSpecific(key: key, value: ())
returnkey
}()
static var isMain: Bool {
return DispatchQueue.getSpecific(key: token) != nil
}
}
网友评论