Search code examples
objective-cios6

What about iPod #define constants?


When I try to define my constants here, I don't have any experiences about iPod:

#define isIPhone (![[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] || [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

Can anyone know how to define the iPod models?


Solution

  • Use the properties of [UIDevice currentDevice]: UIDevice reference

    Branching based on resolution is definitely a bad idea.

    See also: UIDevice currentDevice model possible values

    As this info is not going to change at run time, it is worth querying it once at the beginning, rather than calling the corresponding API at each specific conditional.