JAHelia
JAHelia

Reputation: 7922

#define macro does not take variable values

I have created #define statement in project's pch file so it can be seen in all files in the project, the statement is: #define MYURL(x,y) @"http://internal-sps/providers.aspx?category=(a)&regionID=(y)"

however, I use this macro in any file inside the project like this:

NSString *url = MYURL(@"category1",@"3");

then NSLog(@"%@", url); the console shows this:

http://internal-sps/providers.aspx?category=(a)&regionID=(y) not the actual values.

how can i get the actual values for this macro ?

Upvotes: 0

Views: 1335

Answers (1)

Paul R
Paul R

Reputation: 212959

Change:

#define MYURL(x,y) @"http://internal-sps/providers.aspx?category=(a)&regionID=(y)"

to:

#define MYURL(x,y) "http://internal-sps/providers.aspx?category=(a)&regionID=("y")"

and use your macro like this:

NSString *url = @MYURL("category1","3");


Note: if that a is actually meant to be an x then it would be:

#define MYURL(x,y) "http://internal-sps/providers.aspx?category=("x")&regionID=("y")"

Upvotes: 3

Related Questions