Binarian
Binarian

Reputation: 12446

How to access enum constants from API?

I want to access an enum from another class.

var preferenceButton: UIButton = UIButton(frame: CGRectMake(288.0, view.bounds.size.height - 32.0, 32.0, 32.0))
preferenceButton.setBackgroundImage(image: UIImage(named: @"preferenceIcon"), forState: UIControlStateNormal) // this does not work, because UIControlStateNormal is not known

In the Apple docs this is an example

OBJECTIVE-C

UITableView *myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];

SWIFT

let myTableView: UITableView = UITableView(frame: CGRectZero, style: .Grouped)

But this does not work for me, maybe because UITableViewStyleGrouped is declared in the UITableView class?

Upvotes: 1

Views: 1032

Answers (1)

Tomáš Linhart
Tomáš Linhart

Reputation: 14329

Have you imported UIKit?

import UIKit

You can also try to specify entire name.

UITableViewStyle.Grouped

Upvotes: 3

Related Questions