Reputation: 172
It gives the following error "instance member 'isDeviceiPad' cannot be used on type 'MyView'"
code:
class MyView: UIView {
let isDeviceiPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad)
let itemWidth:CGFloat = isDeviceiPad ? 10.0 : 5.0
}
What is the reason? any idea?
Upvotes: 0
Views: 145
Reputation: 4050
or you can make it a computed property
class MyView: UIView {
let isDeviceiPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad)
var itemWidth:CGFloat {
return isDeviceiPad ? 10.0 : 5.0
}
}
Upvotes: 2