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
}
I am new to iOS, I want to create a NSMutableDictionary
of UIButton
but it give the following error:
Cannot cast 'UIButton' to 'NSCopying'.
I don't understand why this error occurs.
Thanks in advance.