Jason
Jason

Reputation: 634

Use of unresolved identifier 'UIUserInterfaceIdiomPad'

I've created a new Swift-based project using Xcode 7.2. Upon writing the following code within the viewDidLoad() method in my ViewController.swift file:

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad {

}

I get the error message "Use of unresolved identifier 'UIUserInterfaceIdiomPad'", and the compiler won't proceed.

I suspected it was something to do with the "import UIKit" at the top? For some reason if I delete that line and begin typing "import UI" it doesn't provide me autocomplete options at all.

Things I've tried:

Questions:

Thanks!

Upvotes: 1

Views: 2613

Answers (1)

Pushpa Y
Pushpa Y

Reputation: 1010

Try to use

Swift 2

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad {

}

Swift 3

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {

}

instead of

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad {

}

Hope it help you .. :)

Upvotes: 5

Related Questions