Saturday, June 13, 2026
HomeiOS Developmentios - Occasion member can't be used on sort, and asks if...

ios – Occasion member can’t be used on sort, and asks if I wish to use worth

[ad_1]

For some cause, I get the error in 2 totally different spots in my code for a firebase supervisor to add information to the cloud:

Occasion member ‘identify’ can’t be used on sort ‘userManager’; did you imply to make use of a price of this kind as an alternative?andOccasion member ‘id’ can’t be used on sort ‘userManager’; did you imply to make use of a price of this kind as an alternative?

import Basis
import Firebase

class ViewModel: ObservableObject {
    
    @Printed var checklist = [userManager]()
    
    func updateData(userManagerToUpdate: userManager) {
        
        // Get a reference to the database
        let db = Firestore.firestore()
        
        // Set the info to replace
        db.assortment("userManager").doc(userManagerToUpdate.id).setData(["name":"Updated: (userManager.name)"], merge: true) { error in //error 1 right here
            
            // Test for errors
            if error == nil {
                // Get the brand new information
                self.getData()
            }
        }
    }
    
    func deleteData(userManagerToDelete: userManager) {
        
        // Get a reference to the database
        let db = Firestore.firestore()
        
        // Specify the doc to delete
        db.assortment("userManager").doc(userManagerToDelete.id).delete { error in
            
            // Test for errors
            if error == nil {
                // No errors
                
                // Replace the UI from the primary thread
                DispatchQueue.fundamental.async {
                    
                    // Take away the todo that was simply deleted
                    self.checklist.removeAll { todo in
                        
                        // Test for the todo to take away
                        return userManager.id == userManagerToDelete.id //error 2 right here
                    }
                }
                
                
            }
        }
        
    }
    
    func addData(identify: String, notes: String, bio: String, deal with: String, worth: Bool) {
        
        // Get a reference to the database
        let db = Firestore.firestore()
        
        // Add a doc to a group
        db.assortment("userManager").addDocument(information: ["name":name, "bio":bio, "address":address, "price":price]) { error in
            
            // Test for errors
            if error == nil {
                // No errors
                
                // Name get information to retrieve newest information
                self.getData()
            }
            else {
                // Deal with the error
            }
        }
    }
    
    func getData() {
        
        // Get a reference to the database
        let db = Firestore.firestore()
        
        // Learn the paperwork at a particular path
        db.assortment("userManager").getDocuments { snapshot, error in
            
            // Test for errors
            if error == nil {
                // No errors
                
                if let snapshot = snapshot {
                    
                    // Replace the checklist property in the primary thread
                    DispatchQueue.fundamental.async {
                        
                        // Get all of the paperwork and create Todos
                        self.checklist = snapshot.paperwork.map { d in
                            
                            // Create a Todo merchandise for every doc returned
                            return userManager(id: d.documentID,
                                               identify: d["name"]  as? String ?? "", deal with: ["address"] as? String ?? "", bio: ["bio"] as? String ?? "", worth: ["price"] as? String ?? "")
                        }
                    }
                }
            }
            else {
                //Deal with the error
            }
        }
    }
}

I’ve tried altering across the syntax for each, however nonetheless have gotten extra errors.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments