Post

Replies

Boosts

Views

Activity

Reply to @Binding var updates only once
@Claude31 Maybe I found the reason for this strange behavior: the problem seems to be in the Equatable implementation I made for the Subject structure. I thought the Equatable was involved only when dealing with lists and selections: only today (unable to see updates "randomly" after editing a resource), I realize that the Equatable seems to rule also the redraw of the containing view. Following my first interpretation, I checked for Equality only the 4 main attributes, thus any change made to the other attributes had no influence on inequality. Now I added a lastUpdate timeStamp to the struct, always up-to-date with updates and placed it in the Equatable == function. Even if I turn-arounded my original problem using a temporary Observable Class editSubject, I'll study deeper this behavior, making a test project where in the Equatable are compared ALL the structures attributes... just to be sure to fully understand this, that seems to be a very basic for SwuiftUI, but not so emphasized in documentation (all sample are always too simple, compared to real life needs, unfortunately). If you are interested, I'll keep you posted. And maybe could be useful for others :) (Editing, 'cose I forgot to tell..) of course, it seems to be an error of mine!
2w
Reply to @Binding var updates only once
@Claude31 Hi, Claude. Subject can't be @Observable, because only classes can be that and it's a struct. From the code (to keep it short) I omitted the observable class that embeds the subjects array, because it doesn't make any difference. In the Apple sample project the piece of code I posted works perfectly... and stops to work once copied to the new project created in Xcode 16 :)
3w