Reputation: 2444
I have a typealias as follow:
typealias Member = (memberId: Int64?,fullName: String?,photoUrl: String?)
when I call this as follow
Member(memberid: 14, fullname: "Nifras", photourl: "Hello")
I got the error like this
Cannot invoke initializer for type 'Member' with an argument list of type '(memberid: Int64?, fullname: String?, photourl: String?)'
Upvotes: 1
Views: 74
Reputation: 1741
If you want to use Member(memberId: 14, fullName: "Nifras", photoUrl: "Hello")
syntax, you have to create struct Member
:
struct Member {
memberId: Int64?
fullName: String?
photoUrl: String?
}
You can read more about structures https://docs.swift.org/swift-book/LanguageGuide/ClassesAndStructures.html
Upvotes: 1
Reputation: 318854
Member
is an alias for a tuple. You are trying to create an instance of a Member
like calling an initializer for a class or struct.
You want:
let someVar: Member = (14, "Nifras", "Hello")
Or you can use Member
as a type for a parameter or return type.
func someFunc(someParam: Member)
or
func someFunc() -> Member
Upvotes: 2