Post

Replies

Boosts

Views

Activity

SwiftUI - Passing a variable to Observable Object
I have a view that's receiving an ID value from the previous view. I need to also take that ID value and pass it into an ObservableObject so that I can run a Firestore query on that ID. I'm at a loss as to how to grab that ID for my ObservableObject.import SwiftUI import Firebase struct ItemsView: View { var itemName: String var itemID: String @ObservedObject var items = getItemsData() // ....etc } class getItemsData() { @Published var data = [items]() init() { let db = Firestore.firestore() db.collection("items").whreField("itemID", isEqualTo: "THIS IS WHERE I NEED TO PASS THE VALUE OF itemID").addSnopshotListenserSo in the query call, I need to call the ItemID value to query based on that value that's defined at the top of the view.
1
0
2.6k
Mar ’20