[ad_1]
I’ve viewmodel and consider i’ve return some API logic in viewmodel and getting one dictionary after some logic..i wish to entry that dictionary worth from view for ex.
viewmodel.someDic
however for now every-time i get empty dic.
class Viewmodel {
@State non-public var poductDetails:[String:ProductDetail] = [:]
func createItems(knowledge: ProductRootClass) {
var productDetils = [String: SelectedProductDetail](){
//some logic
productDetils // with some object
self.poductDetails = productDetils
}
}
}
struct View: View {
var viewModel: ViewModel
var physique: some View {
VStack(alignment: .main) {
Textual content("(viewModel.poductDetails)")
}
}
}
I wish to entry this dictionary from view.
I attempted accessing by returning productDetils from any operate however get empty everytime.
could i know how to entry property from viewmodel to view?
[ad_2]
