Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write if condition in #ifdef. for Staging. in objective-c

I need to add one more condition inside this call Staging..

how to do it in this condition.

  #ifdef MYAPP_PRODUCTION         buildMode = @"Production";     #else      #ifdef MYAPP_RELEASE         buildMode = @"Release";     #else MYAPP_DEBUG        buildMode = @"Debug";     #endif     #endif 

another is MyApp_Staging need to include in this if condition how to do this?

like image 519
user891268 Avatar asked Aug 26 '11 13:08

user891268


People also ask

How do you write or in if conditions?

OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False) NOT – =IF(NOT(Something is True), Value if True, Value if False)

What is if condition example?

if (score >= 90) grade = 'A'; The following example displays Number is positive if the value of number is greater than or equal to 0 . If the value of number is less than 0 , it displays Number is negative . if (number >= 0) printf("Number is positive\n"); else printf("Number is negative\n");

Can IF statement have 2 conditions?

Use two if statements if both if statement conditions could be true at the same time. In this example, both conditions can be true. You can pass and do great at the same time. Use an if/else statement if the two conditions are mutually exclusive meaning if one condition is true the other condition must be false.

Can we write if condition in else?

Yes, placing an if inside an else is perfectly acceptable practice but in most cases use of else if is clearer and cleaner.


2 Answers

You could do something like this to contain all the different options including the new Staging Mode and make the whole statement cleaner:

#ifdef MYAPP_PRODUCTION     buildMode = @"Production"; #elif MYAPP_RELEASE     buildMode = @"Release"; #elif MYAPP_DEBUG     buildMode = @"Debug"; #elif MYAPP_STAGING     buildMode = @"Staging"; #endif 
like image 151
Suhail Patel Avatar answered Sep 20 '22 21:09

Suhail Patel


Your question is not very clear... If you want multiple conditions in a #ifdef, here is a solution:

#if defined(MYAPP_RELEASE) && defined(MyApp_Staging)     // ... #else     // ... #endif 
like image 35
jv42 Avatar answered Sep 21 '22 21:09

jv42