2016-08-17 6 views
3

は、私はエラータイプ '() - > Void'の値を '(() - > Void)'に割り当てることはできません! '入力する - '>ボイド()' 8ベータ6をXcodeのために更新した後

型の値を割り当てることができません取得しています '(() - >ボイド)!'修正の

// Button sub-class 
public class SCLButton: UIButton { 
    var actionType = SCLActionType.none 
    var target:AnyObject! 
    var selector:Selector! 
    var action:(()->Void)! 

    public init() { 
     super.init(frame: CGRect.zero) 
    } 

    required public init?(coder aDecoder: NSCoder) { 
     super.init(coder:aDecoder) 
    } 

    override public init(frame:CGRect) { 
     super.init(frame:frame) 
    } 

// required public init?(coder aDecoder: NSCoder) { 
//  fatalError("init(coder:) has not been implemented") 
// } 
} 
public func addButton(_ title:String, action:()->Void)->SCLButton { 
    let btn = addButton(title) 
    btn.actionType = SCLActionType.closure 
    btn.action = action // here is where the error occurs 
    btn.addTarget(self, action:#selector(SCLAlertView.buttonTapped(_:)), for:.touchUpInside) 
    btn.addTarget(self, action:#selector(SCLAlertView.buttonTapDown(_:)), for:[.touchDown, .touchDragEnter]) 
    btn.addTarget(self, action:#selector(SCLAlertView.buttonRelease(_:)), for:[.touchUpInside, .touchUpOutside, .touchCancel, .touchDragOutside]) 
    return btn 
} 

任意の提案:以下FUNCブロック、3行目の

+0

エラーメッセージでは、期待される型が '(() - > Void)!'(暗黙的にアンラップされたオプション)ですが、 'パラメータ。タイプが一致しません。 – vadian

+0

更新された質問を確認する@ozgur –

+0

私は何を調整する必要がありますか? @vadian –

答えて

5

あなたの問題は、これに関連しているようだ: SE-0103

にごaddButton(_:action:)の方法ヘッダーをchaging試してみてください:新しいベータ版からの診断メッセージは、いつものように混乱して不十分である

public func addButton(_ title:String, action:@escaping()->Void)->SCLButton { 

、あなたの財産を単に非 - オプションのvar action:()->Void = {}にすると、もう少し便利な情報が得られます。

関連する問題