我有如下类型别名:
sess_k92fdn46onm5an0mau6p50tr2g
当我这样称呼
时typealias Member = (memberId: Int64?,fullName: String?,photoUrl: String?)
我遇到了这样的错误
无法使用参数列表为'Member'调用初始化程序 类型'((memberid:Int64 ?,全名:String ?, photourl:String?)'
答案 0 :(得分:2)
Member
是元组的别名。您正在尝试创建Member
的实例,例如为类或结构调用初始化程序。
您要
let someVar: Member = (14, "Nifras", "Hello")
或者您可以将Member
用作参数的类型或返回类型。
func someFunc(someParam: Member)
或
func someFunc() -> Member
答案 1 :(得分:1)
如果要使用Member(memberId: 14, fullName: "Nifras", photoUrl: "Hello")
语法,则必须创建struct Member
:
struct Member {
memberId: Int64?
fullName: String?
photoUrl: String?
}
您可以阅读有关结构https://docs.swift.org/swift-book/LanguageGuide/ClassesAndStructures.html
的更多信息