Search code examples
objective-ctvos

What is the best way to conditionally compile under tvOS


Given an iOS function like so:

+ (UIView*) aView
{
  UIScreen *screen = [UIScreen mainScreen];
  CGRect rect = screen.applicationFrame;
  return [[UIView alloc] initWithFrame:rect];
}

This fails to compile under tvOS because UIScreen.applicationFrame is not defined. What is the best pre-processor symbol to check specifically for tvOS?


Solution

  • TARGET_OS_TV from TargetConditionals.h