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
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
Hi everybody, after updating to 14 iOS ran into a problem. When calling Sheet, there is a later update of the variable from the second time. I will give an example:
@State var showTestSheet : Bool = false
@State var testVar : Bool = false
Button(action:
{
self.testVar.toggle()
		self.showTestSheet = true
			}) {
				 Text("Test")
}
.sheet(isPresented: self.$showTestSheet, content: {
if(self.testVar) {
		 Text("True")
} else {
		 Text("False")
}})
The first time the button is clicked, the testVar variable changes, but inside sheet it is not changed. When you press the button again, everything works as expected. On iOS 13 everything works without errors. Maybe I'm doing something wrong or I missed the information that something has changed. If anyone comes across, help or tell me where to look. Very grateful in advance for any answer.