Dennislay
Dennislay

Reputation: 1

Value of type 'UIButton' has no member 'enumerate'

func addButtonConstraints(buttons:UIButton, mainView:UIView) {
    for(index, buttons) in buttons.enumerate{

but xcode give me this error --->Value of type 'UIButton' has no member 'enumerate'

Upvotes: 0

Views: 950

Answers (1)

Frankenstein
Frankenstein

Reputation: 16341

The enumerate property is a member of Array. So here there is only one UIButton it can't be enumerated unless it is [UIButton].

Replace:

func addButtonConstraints(buttons:UIButton, mainView:UIView) {
    for(index, buttons) in buttons.enumerate{

With:

func addButtonConstraints(buttons: [UIButton], mainView: UIView) {  
    for (index, button) in buttons.enumerated() {

Upvotes: 1

Related Questions