0

Swift 报错 Return from initializer without initializing all stored properties

paula created at6 years ago view count: 328
class Http{
  var host : String
  var port : Int64
  public func init(){
 }
}

然后Xcode 会提示错误

Return from initializer without initializing all stored properties

report
回复
0

init需要初始化所有要存储的属性

public func init(host:String, port:Int64){
   self.host = host
   self.port = port
}
6 years ago 回复
0
jk #

把属性改为可选类型就可以了。 var host : String?

6 years ago 回复

相关搜索关键词