Is it possible to conditionally enable the protocol? For example, below is code that doesn't work, but should give you an idea of ββwhat I mean. I want the AdWhirlDelegate interface to be enabled if ads are enabled.
// this works fine #if ADS_SUPPORTED #import "AdWhirlView.h" #endif // this does NOT work @interface MyAppDelegate : NSObject <UIApplicationDelegate #if ADS_SUPPORTED ,AdWhirlDelegate #endif>
You can do:
#if ADS_SUPPORTED @interface MyAppDelegate : NSObject <UIApplicationDelegate,AdWhirlDelegate> #else @interface MyAppDelegate : NSObject <UIApplicationDelegate> #endif
... but then IB can get a little confused. See this answer for an alternative to this.
This will not work
Repeat the interface declaration twice, one with the protocol and one without locking inside the structure # if / # else / # endif
Preprocessor directives will only work in a non-nested manner, like your header.
Source: https://habr.com/ru/post/891836/More articles:.htaccess 500 internal server error installing ExpiresActive - .htaccessDo something when the jQuery plugin loads - javascriptC ++ stl-compatible iterator iterator - c ++Problems with the Celery Demon - djangoHow can I conditionally declare a delegate in an interface declaration? - iosCGAL: intersection between segment and polygon? - computational-geometryIs it possible to have an array that lazily evaluates its elements? - performanceHow to use different interface declarations at compile time without confusing the Builder interface - iosAdjust width based on parent w / jQuery - javascriptHow to distinguish bind () in sys / sockets.h and std :: bind? - c ++All Articles