Reputation: 475
so in my ContentView, I'm creating a view with:
ViewName(variable: ObservedObjectInstance)
where variable is the name of an initialization parameter required for the view; it takes in something of the same type as the ObservedObjectInstance. The ObservedObjectInstance is an @ObservedObject variable that was declared as a struct-level variable. In the ViewName class, I'd like to be able to access ObservedObjectInstance but I'm not sure how. I tried just declaring the following as a struct-level variable:
var variable: ObservedObjectClassType
and then in the PreviewProvider, I tried doing the following:
ViewName(variable: variable)
but it didn't work. I'm pretty sure the declaration of 'variable' in the ViewName class and the PreviewProvider is what's wrong, but I'm not sure how to fix it. Any help would be greatly appreciated.
Upvotes: 1
Views: 541
Reputation: 257693
In PreviewProvider use the following
ViewName(variable: ObservedObjectClassType())
Upvotes: 1