0

Possible Duplicate:
How can I programmatically determine if my app is running in the iphone simulator?

How I can check in XCode 4 with constant if my program is running in simulator o device? Something like this:

#ifdef RUNING_ON_DEVICE
#else
#endif
Community
  • 1
  • 1
BQuadra
  • 789
  • 2
  • 11
  • 20
  • 1
    Check this: http://stackoverflow.com/questions/458304/how-can-i-programmatically-determine-if-my-app-is-running-in-the-iphone-simulato – vmariano Sep 08 '12 at 14:59

1 Answers1

6

There are a couple of options

Preprocessor macro:

#if TARGET_IPHONE_SIMULATOR
//is sim
#elif TARGET_OS_IPHONE
//is real device
#else
//unknown target
#endif

Or, if you'd rather do it in some arbitrary method:

if ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"]) {
    //device is simulator
}
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281