Stavo osservando l'esempio di Apple Lister (for Apple Watch, iOS, and OS X). Il campione esegue un test per iOS e OS X:Macro preprocessore per Apple Watch?
#import <TargetConditionals.h>
#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
@import ListerKit;
#elif TARGET_OS_MAC
@import ListerKitOSX;
#endif
Tuttavia, non v'è alcuna prova per TARGET_OS_WATCH
o simili. Grep per watch
in TargetConditionals.h
non esprima alcun successi:
$ cat /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
/SDKs/iPhoneOS7.1.sdk/usr/include/TargetConditionals.h | grep -i watch
$
Da TargetConditionals.h
, so che ci sono:
These conditionals specify in which Operating System the generated code will run. The MAC/WIN32/UNIX conditionals are mutually exclusive. The EMBEDDED/IPHONE conditionals are variants of TARGET_OS_MAC. TARGET_OS_MAC - Generate code will run under Mac OS TARGET_OS_WIN32 - Generate code will run under 32-bit Windows TARGET_OS_UNIX - Generate code will run under some non Mac OS X unix TARGET_OS_EMBEDDED - Generate code will run under an embedded OS variant of TARGET_OS_MAC TARGET_OS_IPHONE - Generate code will run under iPhone OS which is a variant of TARGET_OS_MAC. TARGET_IPHONE_SIMULATOR - Generate code for running under iPhone Simulator
Domanda: Esiste un preprocessore per l'orologio di Apple?
sto tagging con ios, ma non sono sicuro che sia il sistema operativo corretto per questa domanda.
L'elenco seguente è stato compilato da iPhone TargetConditionals.h
. Il simulatore e OS X sono simili (hanno appena diversi bit impostato a 1):
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_EMBEDDED 1
#define TARGET_OS_IPHONE 1
#define TARGET_IPHONE_SIMULATOR 0
Domande: Fa l'uso dell'orologio TARGET_OS_EMBEDDED
? L'orologio ometteTARGET_OS_IPHONE
?
Potresti avere una classe manager condivisa che richiama [UIApplication sharedApplication] che è vietata sulla watch ma sai che non sarà mai essere chiamato o potrebbe voler sovrascrivere usando questa macro. – ge0rges