l0gg3r
l0gg3r

Reputation: 8954

#define change multi-parameter method name

I have a method

- (void)hello:(NSString *)a world:(NSString *)b

which I want to rename (using preprocessor macro)

- (void)hello_obf:(NSString *)a world_obf:(NSString *)b

So I have tried

#define hello:world hello_obf:world_obf

which actually doesn't work, is there any solution to rename a multi-parameter objective c method using #define?

The only solution I have found is to define method name separately, ex.

#define hello hello_obf
#define world world_obf

which doesn't work for me, as it can mess my other code.

Upvotes: 0

Views: 46

Answers (1)

rici
rici

Reputation: 241931

Short Answer: No.

Preprocessing happens before any kind of semantic or even syntactic analysis. The preprocessor knows nothing about the structure of the programs it is working on, since the structure hasn't been defined yet. So it knows nothing about Objective-C methods.

Basically, the preprocessor takes a stream of tokens as input and produces a stream of tokens as output. Since it does not parse the token stream, it has no concept of Objective-C methods, or C++ templates, or anything else which involves the semantics of an identifier.

Upvotes: 1

Related Questions