Absolutely! Just remember that #define
is a simple text replacement before compilation: you want kClass
to be UIColor
, not [UIColor class]
, just as you would never write @interface [UIColor class] (MyCategory)
.
In conclusion:
#if TARGET_OS_IPHONE
#define kClass UIColor
#import <UIKit/UIKit.h>
#elif TARGET_OS_MAC
#define kClass NSColor
#import <AppKit/AppKit.h>
#endif
@interface kClass (MyCategory)