@Transient update doesn't propagate to view

When I update a variable inside my model that is marked @Transient, my view does not update with this change. Is this normal? If I update a non-transient variable inside the model at the same time that I update the transient one, then both changes are propagated to my view.

Here is an example of the model:

@Model public class WaterData {
    public var target: Double = 3000
    @Transient public var samples: [HKQuantitySample] = []
}

Updating samples only does not propagate to my view.

I am also seeing this issue @rolandkajatin. Coincidentally, my @Transient marked property is also using HealthKit with a type of HKCategorySample?.

Same here, it seems you not only have to update the non-transient property but also reference both in the body of the view to see the changes propagated. Is there a simple workaround to this? I need to update my view when a transient property is mutated but I don't want to add unnecessary code, will this be fixed or is it the expected behavior for transient properties?

I was having this problem as well and adding the field to the list view didn't help as per emiliocortina's suggestion.

Due to the issue with @Transient in Xcode 15 Betas I was using the following successfully through Beta 5.

@Attribute(.transient) var isChecked = false

Beta 6 broke a number of things for me, related to defaults and then in Beta 7 those were corrected but the above code didn't compile as .transient was removed. I tried moving back to @Transient macro but it still doesn't update the view correctly. However, I did find that there is a new ephemeral option that has been added which seems to work the same as my earlier .transient. The following change got me up and running again.

@Attribute(.ephemeral) var isChecked = false

Seems like documentation hasn't been updated and there is no reference to this in the release notes either.

Try changing your code to the following and see if this works -- you'll probably need to be running Xcode 15 Beta 7 or higher:

@Attribute(.transient) public var samples: [HKQuantitySample] = []

Let us know how it works!

Looks promising, but it doesn't work. I get the error saying HKQuantitySample does not conform to PersistentModel.

I just don't see a way to get this to work at this point.

@Transient still does not publish in XCode 15.0 (non beta)

@Attribute(.ephemeral) var isChecked = false

does work for me, for the time being.

Still an issue Xcode 15.2 non beta

@Transient update doesn't propagate to view
 
 
Q