Why Can't I do var test: some View?

I want to have a property in a struct/class where it is of type custom View e.g.

var view: some View?

So many issues here, I ended up doing

var view: AnyView?

But i got stuck here because whenever I assign a value to this, the app crashes. saying

Could not cast value of type '__NSCFNumber' (0x7fdcdf9c3480) to 'NSString' (0x1192bac50).

This i do not understand

view should be some view so it si neither number nor string. any idea why?

also. if i do this

var view: (some View)?

it is ok. but when i set a value to that property it says Cannot assign value of type 'DailyCityReportView' to type 'some View'

My goal is to pass a custom view to a property.

Accepted Answer

Please ignore. Seems the problem lies in the DailyCityReportView.

Why Can't I do var test: some View?
 
 
Q