Swift3 获取错误-在属性访问中使用self';风格';在self.init初始化self之前

Swift3 获取错误-在属性访问中使用self';风格';在self.init初始化self之前,swift3,Swift3,这正是tin上所说的:在属性初始化之前,不能使用它 您正在将值style传递给指定的初始值设定项,该初始值设定项设置style的值。也许你想通过preferredStyle`而不是 private extension UIAlertAction { convenience init(title: String?, preferredStyle: UIAlertActionStyle, buttonIndex:Int, t

这正是tin上所说的:在属性初始化之前,不能使用它

您正在将值
style
传递给指定的初始值设定项,该初始值设定项设置
style的值。也许你想通过
preferredStyle`而不是

private extension UIAlertAction {
    convenience init(title: String?, 
                preferredStyle: UIAlertActionStyle, buttonIndex:Int, 
                tapBlock:((UIAlertAction,Int) -> Void)?) { 
        self.init(title: title, style: style) {
            (action:UIAlertAction) in
            if let block = tapBlock {
                block(action,buttonIndex)
            }
        }
    }