iosobjective-ciphoneios-simulatorcompiler-directives

Conditional compile when running in Simulator as opposed to on a device


Is there a compiler directive I can use to compile a different line of code when targetting the simulator as opposed to my device. Something like:

# IF SIMULATOR
[self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
# ELSE
[self.imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
# END

EDIT

Direct link to docs.


Solution

  • #if TARGET_IPHONE_SIMULATOR
    [self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    #else
    [self.imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    #endif