美文网首页
2019-10-21

2019-10-21

作者: Dove_iOS | 来源:发表于2019-10-21 16:43 被阅读0次

问题:
Keyword 'init' cannot be used as an identifier here,If this name is unavoidable, use backticks to escape it -> init
'convenience' may only be used on 'init' declarations
Static member 'init' cannot be used on instance of type 'ViewController', Insert 'ViewController.'

翻译:
此处不能将关键字“init”用作标识符,如果此名称不可避免,请使用倒勾号将其转义->init

“便利”只能用于“init”声明

静态成员“init”不能用于“viewcontroller”类型的实例,请插入“viewcontroller”。

解释:
"init"是系统关键字, 所以不能直接使用, 要用倒勾号将其转义init

遍历构造器只能用于“init”声明

静态成员“init”不能用于“viewcontroller”类型的实例, 如下使用:

声明:
public static func init(str: String) {

}
调用:
ViewController.self.init(str: "123")

声明
func init(str: String) {

}
调用:
let vc = ViewController()
vc.init(str: "123")

相关文章

网友评论

      本文标题:2019-10-21

      本文链接:https://www.haomeiwen.com/subject/qsntvctx.html