I obviously do use something like this ...
#import <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR
// Simulator specific code
#else // TARGET_IPHONE_SIMULATOR
// Device specific code
#endif // TARGET_IPHONE_SIMULATOR
And to your second question ... Something like this should help you. In your app delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ( ! [[NSUserDefaults standardUserDefaults] boolForKey:@"initialized"] ) {
// Setup stuff
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"initialized"];
}
... your code ...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…