Skip to content

Instantly share code, notes, and snippets.

View vialyx's full-sized avatar
🎯
Focusing

Maxim Vialyx vialyx

🎯
Focusing
View GitHub Profile
<JsonCoddableUrlSession.ViewController: 0x7fc17051ac40> retrive flights: [JsonCoddableUrlSession.FlightData(Airline: "AEROFLOT", Flight: "SU1834", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "AEROFLOT", Flight: "SU1838", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2776", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2936", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2736", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2848", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2944", ActualTime: ""), JsonCoddableUrlSession.FlightData(Airline: "BELAVIA", Flight: "B2954", ActualTime: "")
DispatchQueue.init(label: "defaultQos").sync {
print("sync defaultQos exec")
// 1
}
DispatchQueue.init(label: "defaultQos").async {
print("async defaultQos exec")
// 3
}
let concurent = DispatchQueue.init(label: "defaultQos", attributes: .concurrent)
concurent.sync {
print("sync defaultQos exec")
// 1
}
concurent.sync {
print("sync defaultQos exec")
// 2
}
DispatchQueue.init(label: "defaultQos").async {
print("async defaultQos exec")
// 2
DispatchQueue.main.async {
print("async main exec")
// 3
}
}
print("sync main exec")
let background = DispatchQueue.init(label: "background", qos: .background)
// Work takes significant time, such as minutes or hours.
let utility = DispatchQueue.init(label: "utility", qos: .utility)
// Work takes a few seconds to a few minutes.
let `default` = DispatchQueue.init(label: "default", qos: .default)
// The priority level of this QoS falls between user-initiated and utility. This QoS is not intended to be used by developers to classify work. Work that has no QoS information assigned is treated as default, and the GCD global queue runs at this level.
let userInitiated = DispatchQueue.init(label: "userInitiated", qos: .userInitiated)
let workItemFirst = DispatchWorkItem {
print("exec 1st WI")
// 2
}
let workItemSecond = DispatchWorkItem {
print("exec 1st WI")
// Not called
}
let group = DispatchGroup()
let workItemFirst = DispatchWorkItem {
print("exec 1st WI")
// 1
group.leave()
}
let workItemSecond = DispatchWorkItem {
print("exec 2nd WI")
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class MyViewController: UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class MyViewController: UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white