I am trying to set up a simple User object in my app, when I try to initialize the object or access it's parameters I'm not able to do so, it usually throws the following error:
Argument passed to call that takes no parameters
This feels like a beginner's issue but I have no idea why it's happening.
Here's the code I use for the object:
import Foundation
import Firebase
class User {
var username: String
var image: String
var email: String
init(username: String, image: String, email: String) {
self.username = username
self.image = image
self.email = email
}
func toAny() -> [String: Any] {
return ["username": username, "image": image, "email": email]
}
}
and then I imagine I should be able to do:
let user = User(username: "usr", image: "img", email: "mail")
but that doesn't work, it throws the error mentioned above
So I tried instantiating the object in the scope like:
let user: User?
and then
user.username = "usr"
but that didn't work either...
I have been working with Swift apps for over 2 years and I still have issues with the simplest of things sometimes, but since I can't find any great references online I thought I'd try my luck here. Though I agree it's a silly question I would love an explanation of what I'm doing wrong and how to never encounter this issue again.
It's due to the ambiguity between User
created by you and the User
class in the FirebaseAuth Framework
Try renaming your User
class to something more specific to your use-case. Accessing its variables should not cause any issue.