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.
Post
Replies
Boosts
Views
Activity
Hi, When an achievement is completed and the value of this property is true, a notification banner is displayed to the player to inform them of the completed achievement. I wonder if at least one person eats from whom it opens? I tried to figure out what was the matter. For the test, I made 2 buttons in one reset of achievements and in the other an addition:
Button (action: {
GKAchievement.resetAchievements { (error) in
print("Done")
}
}) {
Text("RESET")
}
AND
let achievement = GKAchievement(identifier: "ident")
achievement.percentComplete = 100.0
achievement.showsCompletionBanner = true
GKAchievement.report([achievement]) { (error) in
if error != nil {
print(error!.localizedDescription)
} else {
print("Done")
}
}
and found that the banner is shown if immediately after resetting the results. if more than a second passes before pressing the second button, then the banner will no longer be shown. If anyone has come across this, tell me this, am I doing something wrong or a bug?
P.S. GKNotificationBanner shown without problems
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
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