Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Objective-C support #elifdef?

I can't seem to get #elifdef to work in my iOS project. If I do this:

#ifdef X const Foo bar[] = { ... }; #else const Foo bar[] = { ,,, }; #endif 

Then the top one (under X) gets highlighted and the bottom one doesn't. If I do this:

#ifdef W const Foo bar[] = { ;;; }; #elifdef X const Foo bar[] = { ... }; #else const Foo bar[] = { ,,, }; #endif 

Then the bottom one (under else) gets highlighted and the top two don't. Why? Is there another way I should be doing this? I have three targets and they all use the same m file. However, the constants are a bit different for each target so I separate them this way.

like image 784
borrrden Avatar asked May 10 '12 06:05

borrrden


People also ask

How long will Objective-C be supported?

Once the July 31st, 2021 date is reached: No further versions and patches of the Objective-C SDK will be released. All Objective-C SDK download links on the My Workspace ONE portal will be removed or redirected to the Swift SDK download link instead.

Is Objective-C still in use?

Furthermore, Objective-C is a piece of art, creators packed genius solutions and were constantly improving it, so us developers were able to use it at our advantage. There are a lot of indicators telling us there's still a ton of legacy Objective-C code, both from Apple and from other developers, that's still in use.

Is Objective-C still used for iOS development?

Objective-C is so pervasive in iOS that it's impossible to completely remove it. Apple continues to maintain libraries written in Objective-C, so we should expect Objective-C to be treated as a (mostly) first class language in iOS. At other companies, legacy code remains.

Will Objective-C be deprecated?

It won't be deprecated, but it'll move to Florida to enjoy its golden years. It'll spend days running the legacy app with a million lines of code, and its nights sipping margaritas with the OAuth library everyone fears rewriting.


1 Answers

You can simply write:

#elif defined X 

Which should be compatible with all ANSI-C compatible compilers.

like image 95
MByD Avatar answered Oct 03 '22 03:10

MByD