Post

Replies

Boosts

Views

Activity

Reply to SwiftData: var dates: [Date]? or var dates: [Date] = []
So, the lack of a response to what I thought was a pretty straightforward question has me worried that the Apple forums are really focused on much more in depth/interesting questions. I looked for a FAQ, to see if there is any guidance on what kind of questions are considered "appropriate", but as far as I can tell there isn't. I found someone back in 2015 asking about a FAQ, and someone at Apple saying good idea. But still no FAQ. I would try on StackOverflow, but I have found the quality there isn't what it used to be. Anyway, if anyone wants to chime in saying this original question really doesn't meet the requirements here, please do! And for now I am using the Optional approach because it works better for other reasons, and I guess if there is a problem I will find out the hard way once I start dogfooding my app. :)
4w
Reply to Async/Await and updating state
For what it's worth, I did find this thread, which offers a lot of insight and even seems to suggest a definitive answer as to a best practice, but again this is over 2 years ago. In that 25 months I would think Apple would fix the bug and we would be getting some sort of feedback when revising state from an async context, if indeed doing so was still an issue. That said, I think I am going to refactor a few things to use approach #3 from that thread, just to be on the safe side and develop good habits. But I still wonder if in fact this isn't necessary. And, if it IS necessary, and we no longer get any feedback from Xcode when we fail, I wonder what other issues I need to be aware of that Xcode isn't going to draw my attention to?
1w
Reply to Async/Await and updating state
I have also seen it mentioned that @Observable and @MainActor can not be used together, so the old approach of just putting your whole ObservableObject ViewModel on the main actor no longer works. But I just verified that at least as of Xcode 16.1 I can use them both, and when I do my otherwise unmanaged State updates all occur on the main thread, while removing @MainActor on the VM causes all those state updates to occur on background threads. Again with no warning and no crashes. Yet. :)
1w