在MonoTouch中实现 #define 和 #ifdef



我是monoTouch的新手。我在Objective-C中有一个名为"TargetConditions.h"的文件。我正在尝试使用"TargetConditions.h"#define 衍生物。但是,我无法将这些东西放入MonoTouch。这是事情的清单,

#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_IPHONE 1 
#define TARGET_IPHONE_SIMULATOR 1
#ifdef __MACH__
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_MAC_CFM 0
#else
#define TARGET_RT_MAC_MACHO 0
#define TARGET_RT_MAC_CFM 1
#endif

如何将所有 #define 值集成到MonoTouch中?请帮助我摆脱困境。提前谢谢。

将它们替换为类中的常量定义。

public const int TARGET_OS_MAC = 1; 
public const int TARGET_OS_WIN32 = 0; 
public const int TARGET_OS_UNIX = 0; 
public const int TARGET_OS_EMBEDDED = 0; 
public const int TARGET_OS_IPHONE = 1;  
public const int TARGET_IPHONE_SIMULATOR = 1; 
#if __MACH__ 
    public const int TARGET_RT_MAC_MACHO = 1; 
    public const int TARGET_RT_MAC_CFM = 0; 
#else 
    public const int TARGET_RT_MAC_MACHO = 0; 
    public const int TARGET_RT_MAC_CFM = 1; 
#endif 

最新更新