Is there a specific Xcode compiler flag that gets set when compiling for iPad?

后端 未结 6 1485
無奈伤痛
無奈伤痛 2020-12-01 18:43

Is there a specific Xcode compiler flag that gets set when compiling for iPad?

I want to conditionally compile iPad vs iPhone/iPod Touch code for example:

         


        
6条回答
  •  长情又很酷
    2020-12-01 19:24

    Currently I didn’t find anything that would let you check if you are on an iPad, but I’m also not sure if Apple recommends runtime checks. Here’s an excerpt from Apple:

    In addition to your view controllers, any classes that are shared between iPhone and iPad devices need to include conditional compilation macros to isolate device-specific code. Although you could also use runtime checks to determine if specific classes or methods were available, doing so would only increase the size of your executable by adding code paths that would not be followed on one device or the other. Letting the compiler remove this code helps keep your code cleaner.

    However, there is no place I could find more specific information about conditional compilation macros.

提交回复
热议问题