Post

Replies

Boosts

Views

Activity

Trailing closure bug?
i am trying to build my code and have ran into this error. "Trailing closure passed to parameter of type 'DispatchWorkItem' that does not accept a closure" i have been trying to figure it out for so long, and even ai cant figure it out. is this a bug, or am i missing some obvious way to fix this ? func loadUser(uid: String, completion: (() -> Void)? = nil) { db.collection("users").document(uid).getDocument { [weak self] snapshot, error in guard let data = snapshot?.data(), error == nil else { completion?(); return } DispatchQueue.main.async { self?.currentUser = User( username: data["username"] as? String ?? "Learner", email: data["email"] as? String ?? "", profileImageName: "person.circle.fill", totalXP: data["totalXP"] as? Int ?? 0, currentStreak: data["currentStreak"] as? Int ?? 0, longestStreak: data["longestStreak"] as? Int ?? 0, level: data["level"] as? Int ?? 1, levelProgress: data["levelProgress"] as? Double ?? 0.0, xpToNextLevel: data["xpToNextLevel"] as? Int ?? 100, completedLessons: data["completedLessons"] as? [String] ?? [] ) self?.saveUser() completion?() } } }
2
0
152
May ’25