func createRowOfButtons(buttonTitles: [NSString]) -> UIView {
var buttons = [UIButton]()
let keyboardRowView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 50))
var dict = [UIButton:String]()
for buttonTitle in buttonTitles
{
let button = createButtonWithTitle(title: buttonTitle as String)
buttons.append(button)
keyboardRowView.addSubview(button)
dict.updateValue("\(buttonTitle)", forKey: button)
}
allButtons = NSMutableDictionary(dictionary: dict)
//error:[UIButton copyWithZone:]: unrecognized selector sent to instance 0x7e011bc0
addIndividualButtonConstraints(buttons: buttons, mainView:keyboardRowView)
return keyboardRowView
}
を送った私は、私はUIButton
のNSMutableDictionary
を作成するためのiOSの新たいのですが、それは次のエラーを与える:[UIButton copyWithZone:]:認識されていないセレクタはインスタンスへ
Cannot cast 'UIButton' to 'NSCopying'.
を私は理解していませんなぜこのエラーが発生するのですか?
ありがとうございます。
なぜあなたはSwiftで 'NSMutableDictionary'を使う必要がありますか? – Hexfire
それを 'var dict = [UIButton:String]()'から 'var dict = [String:UIButton]()'に戻します。 –