Ali*_*are 35
使用目标.这正是它们的用途.
通常,大多数项目都有一个Target,它对应一个产品/应用程序.如果您定义了多个目标,则可以:
例如,您可以为一个目标定义预编译器宏,为另一个目标定义其他宏(比如OTHER_C_FLAGS = -DPREMIUM在目标"PremiumVersion" OTHER_C_FLAGS = -DLITE中定义,LITE并在"LiteVersion"目标中定义宏),然后在源代码中包含类似的代码:
-(IBAction)commonCodeToBothTargetsHere
{
...
}
-(void)doStuffOnlyAvailableForPremiumVersion
{
#if PREMIUM
// This code will only be compiled if the PREMIUM macro is defined
// namely only when you compile the "PremiumVersion" target
.... // do real stuff
#else
// This code will only be compiled if the PREMIUM macro is NOT defined
// namely when you compile the "LiteVersion" target
[[[[UIAlertView alloc] initWithTitle:@"Only for premium"
message:@"Sorry, this feature is reserved for premium users. Go buy the premium version on the AppStore!"
delegate:self
cancelButtonTitle:@"Doh!"
otherButtonTitles:@"Go buy it!",nil]
autorelease] show];
#endif
}
-(void)otherCommonCodeToBothTargetsHere
{
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6208 次 |
| 最近记录: |