Question: I dont know why my data is not getting read from firebase. Here is my viewControler, contentView, and strut for product. struct ContentView: View {
I dont know why my data is not getting read from firebase. Here is my viewControler, contentView, and strut for product. struct ContentView: View
@ObservedObject var viewController ViewController
var body: some View
VStack
ButtonFetch Data"
viewController.getData
ListviewControllerlist product in
VStackalignment: leading
TextName: productname
TextDescription: productdescription
TextPrice: $productprice
struct Product: Identifiable
let id: String
let name: String
let description: String
let price: Double
class ViewController: ObservableObject
@Published var list Product
func getData
let db Firestore.firestore
dbcollectionProductsgetDocuments snapshot, error in
if let error error
printError getting documents: errorlocalizedDescription
return
if let snapshot snapshot
DispatchQueue.main.async
self.list snapshot.documents.map document in
let data document.data
let name dataname as String
let description datadescription as String
let price dataprice as Double
Generate a unique identifier for each product
let id dataid as String
return Productid: id name: name, description: description, price: price
ShopAppDemo
Read and Write Dat...
Perform simple an
BoundlessArchive..
Cloud Firestore Ge
ChatGPT
Untitled document...
Firebase
ShopAppDemo
Cloud Firestore
Project Overview
Data
Rules
Indexes
Usage
Extensions
Project shortcuts
Firestore Database
Storage
What's new
Products
MlOfeAhllmz
More in Google Cloud
Release Monit...
NEW
Product categories
Build
Release & Monitor
Analytics
Engage
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
