Post

Replies

Boosts

Views

Activity

Sequential execution of asynchronous functions. How?
Hi How to correctly implement such functionality: There is a function call (They are called in a loop) test1(timeout: 10) test2(timeout: 5) test3(timeout: 1) For me, the correct execution should be like this - first, the first function is executed in 10 seconds, then the second in 5 after the first is completed and similarly the third should start 1 second after the second I tried using DispatchQueue and Timer, but nothing worked for me func test1(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish1") completion() } }) func test2(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish2") completion() } }) func test3(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish3") completion() } }) The start of the execution of functions depends on the time, and I need the functions to be executed sequentially as they were started and the time was responsible for the start of execution, but after her turn came
6
0
2.6k
Aug ’21
Sequential execution of asynchronous functions. How?
Hi How to correctly implement such functionality: There is a function call (They are called in a loop) test1(timeout: 10) test2(timeout: 5) test3(timeout: 1) For me, the correct execution should be like this - first, the first function is executed in 10 seconds, then the second in 5 after the first is completed and similarly the third should start 1 second after the second I tried using DispatchQueue and Timer, but nothing worked for me func test1(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish1") completion() } }) func test2(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish2") completion() } }) func test3(timeout: int, completion: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout) { print("finish3") completion() } }) The start of the execution of functions depends on the time, and I need the functions to be executed sequentially as they were started and the time was responsible for the start of execution, but after her turn came
Replies
6
Boosts
0
Views
2.6k
Activity
Aug ’21
DatePicker - The language of the days of the week is always English
Hello I'm trying to change the language DatePicker("", selection: $dt, displayedComponents: .date)       .environment(\.locale, Locale.init(identifier: "ru")) Only a month changes Days of the week always remain English This bug? or Are there any solutions?
Replies
1
Boosts
0
Views
1.6k
Activity
Jul ’21