Frederick C. Lee
Frederick C. Lee

Reputation: 9503

"UIScreen' doesn't have the member 'main'

Environment:
Xcode Version 8.1 beta (8T47)
Apple Swift version 3.0.1 (swiftlang-800.0.56 clang-800.0.42)

The Swift 3.0.1 compiler flagged 'UIScreen' as '...no member'. enter image description here

...but the UIScreen file does have 'main':

@available(iOS 2.0, *) open class UIScreen : NSObject, UITraitEnvironment {

@available(iOS 3.2, *)
open class var screens: [UIScreen] { get } // all screens currently attached to the device

open class var main: UIScreen { get } // the device's internal screen

I found numerous instances of a particular class not having a certain member.
And this was after converting the code to Swift 3.0.1 thru Xcode helper conversion function.
What gives?


Note: I was able to access UIScreen.main.scale via playground.
It appears that I'm working with a corrupt swift file.

Upvotes: 3

Views: 2159

Answers (1)

Sakshi
Sakshi

Reputation: 1040

Swift3.0.1 Since UIScreen is UIKit framework's class.So make sure you have imported.

import UIKit

Upvotes: 3

Related Questions