Post

Replies

Boosts

Views

Activity

Reply to SwiftUI: Sheet presented from List row is not removed from screen when row is removed
Thanks for your reply, sorry for the delay for some reason the alert wasn't enabled for replies despite being the author, I have enabled it now and will try to remember to do that for all my future posts. That's strange you can't reproduce. I can confirm the issue also exists on iOS 18.3.1 device and iOS 18.4 Beta simulator. 18.3.1 test: Xcode Version 16.2 (16C5032a) iOS min deployment 18.2 Swift 5 Language Version Deployed to device: iPhone 14 Pro, iOS 18.3.1 18.4 beta test: Xcode Version 16.3 beta (16E5104o) iOS min deployment 18.4 Swift 5 Language Version Deployed to simulator: iPhone 16 Pro, iOS 18.4 (22E5200m) Just to confirm how to test: the list rows and the sheet are expected to automatically disappear. But only the rows do, i.e. ends up like this:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to @Observable and didSet?
When you mark a class as @Observable you can no longer use didSet because the macro converts it to a computed property. Trying to implement it should really show a warning "this code will never be reached" but it currently doesn't. Observation tracking can reach through computed vars, knowing that, wrapping an underscore observed var in your own computed var should allow you to do your didSet logic, e.g.: private var _test: String = "" // this has the observation logic public var test: String { get { _test // tracking reaches through test to _test } set { _test = newValue // do your didSet logic here } } } I cross posted this answer to my blog https://www.malcolmhall.com/2024/11/21/observable-and-didset/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24