27.12.2012 00:05 Uhr, Quelle: The Unofficial Apple Weblog

Testing for OS X vs iOS

Yesterday, I was messing around building shared NSLayoutConstraint code to be used across iOS and OS X. I put in a few #if TARGET_OS_MAC directives, assuming they'd just work. They didn't. Turns out that you should always check for TARGET_OS_IPHONE first, before TARGET_OS_MAC because the latter is true on the iPhone but the former is not on OS X. Here are some of the most common checks suggested to me yesterday as I messed with this dilemma. #if TARGET_OS_MAC #if TARGET_OS_IPHONE #if TARGET_IPHONE_SIMULATOR #if TARGET_OS_EMBEDDED #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #if defined(__IPHONE_OS_MIN_VERSION_REQUIRED) And here are the results of running them on the Simulator,

Weiterlesen bei The Unofficial Apple Weblog

Digg del.icio.us Facebook email MySpace Technorati Twitter

JustMac.info © Thomas Lohner - Impressum - Datenschutz