Post

Replies

Boosts

Views

Activity

Reply to SwiftUI gets stuck in a view update cycle when I pass down a Binding to a NavigationPath
Thanks for the answer πŸ™‚ When using ObservableObject for such purposes, when passing a navigation path from it to NavigationStack, there is such a problem that there are many unnecessary calls to navigationDestination and unnecessary reinitialization of View from the entire path https://feedbackassistant.apple.com/feedback/14536210 Yeah, that's true. Though that only really happens when the navigation state changes, which doesn't happen too often (since the ObservableRouter is just a Router, not a view model holding lots of states), and most of the times, the paths aren't that deep for it to have a huge impact, I think. And with @Observable unnecessary redraws should occur even less. Additionally, due to the presence of EnvironmentObject, most likely some operations occur that lead to a loop of this process. Yep, I'd love to understand what that loop actually looks like. That's really tricky to find out, unfortunately. Also, it is better to move navigationDestination as close to NavigationStack as possible, i.e. it is better to move it from MiddleView to ContentView. An example according to your code: Is that the case? I've never heard that before πŸ€”Do you have a link where this is stated/explained? That would make me rethink some of the architectural decisions in my app. I assumed the entire purpose of that modifier is to place it anywhere in a NavigationStack, even on sub-pages. The problem with moving everything to ContentView is that you lose all modularity. ContentView would be tightly coupled with MiddleView, which is what I really want to avoid. But if you want to leave it the same, you can use the @State variable for the navigation path, which is synchronized with the path from the Navigator, this will also fix the problem for this particular case, and will reduce the number of unnecessary navigationDestination calls and reinitializations to zero (not on all OS versions), example: I've seen this approach a few times. It does work, yeah, but I don't like it very much, to be honest. It kind of defeats the point of SwiftUI and its state mechanisms. This manual synchronisation is exactly what declarative code is trying to get rid of.
Aug ’24
Reply to "TranslationUnit" - Xcode Previews constantly crash in Xcode 16 Beta 1
Hey, thanks for the reply :) I just started Xcode Beta back up to try and reproduce the issue but now the Previews all work fine. I couldn't make them crash again. I have no idea what changed, I restarted Xcode multiple times yesterday but it kept crashing. Sorry that I cannot provide you with a potentially helpful diagnostics now. I'm going to install the profile nonetheless and try to generate and send you a report whenever the error occurs again.
Jun ’24
Reply to CKSyncEngine - Are the "change batches" we send to iCloud guaranteed to be identical to the batches iCloud sends back to other devices?
Well, that's a bummer πŸ˜… Having a second local database and figuring out when and what to copy to the "real" database seems quite complicated πŸ€”. I'd have to track all incoming changes from CloudKit, map them to their respective tables and then attempt to copy the inserted data (in the correct order) whenever a batch has been handled. If it fails, I try again with the next batch. If it succeeds, I delete the data from the "CloudKit" local database. But that doesn't even cover outgoing changes, which I would have to handle as well. I'm not sure I can do this without missing a gazillion edge cases πŸ˜…. But thanks for your answer :) This at least helps me a bit with the decision whether or not I should continue working on iCloud sync. I'm gonna think about this a bit more. Maybe it's possible to do it. I feel like I'm really close, but the lack of data integrity with CloudKit might just be too much.
Apr ’24