Andreas Larsen
Andreas Larsen

Reputation: 111

Cannot invoke initializer for type '' with an argument list of type ''

UPDATE: This works in Playground and inside a new project but just not inside my current project:

Cannot invoke initializer for type 'User' with an argument list of type '(name: String)'

Any ideas as to what is causing this? I'm using Swift 2.0

class User {
    var name: String
    init (name: String) {
        self.name = name
    }
}
let user1 = User(name: "User")

https://i.sstatic.net/Pm4Fk.png

Upvotes: 1

Views: 4612

Answers (1)

jan.vogt
jan.vogt

Reputation: 1817

This is not the definitiv answer, but it might be the reason that there is another type (protocol, class, struct, enum, PAT,...) called User somewhere within the errorneous project that does not take a string in it's initializer. I remember having experienced that error caused by an accidental name collision.

Upvotes: 1

Related Questions