1

I used Below code in ObjectiveC and worked but in swift giving error.

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 

Help me to get its Swift version.

1
  • 1
    Swift does not support macro like in Objective-C. You can replace them by a variable 'let' like in the answers. Commented Apr 9, 2015 at 14:34

2 Answers 2

5

Alternative in Swift:

let isPad = UIDevice.currentDevice().userInterfaceIdiom == .Pad 
Sign up to request clarification or add additional context in comments.

Comments

1
let isPad = UI_USER_INTERFACE_IDIOM() == .Pad 

2 Comments

got error - use of unresolved identifier UI_USER_INTERFACE_IDIOM
Note that UI_USER_INTERFACE_IDIOM() is commented as to be used only if you deploy for very old versions of iOS. You might want to prefer UIDevice.currentDevice().userInterfaceIdiom instead.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.