I have something like this in my objective-C class
@interface PREFIX_MyClass {
...
@end
and I'd like to use the preprocessor to convert it to:
@interface AwesomeMyClass {
...
@end
so something like
#define PREFIX_ Awesome
doesn't work because it's a part of a word. Any other way? I know I can use something like this:
#define PrefixClass(NAME) Awesome##NAME
@interface PrefixClass(MyClass)
but I don't like this because it breaks code complete and reference following in dev tools (i.e.: Xcode in this case)
This isn't very elegant, but you could use the preprocessor to replace the entire class name instead of just part.
#define PREFIX_MyClass AwesomeMyClass
@interface PREFIX_MyClass
Of course, this becomes an issue if you use the prefix more than once and it changes. You could fix this using by using another calling another macro to add the prefix, so that only one macro contains the actual prefix.
#define ADD_PREFIX(name) Awesome##name
#define PREFIX_MyClass ADD_PREFIX(MyClass)
@interface PREFIX_MyClass
This still requires a macro for everything you want to prefix, but code completion will recognize the PREFIX_MyClass
name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With