views:

900

answers:

1

I want to pass parameter in NSURL i.e. I have NSURL *url = [NSURL URLWithString:@"http://demo.digi-corp.com:82/Nilesh/betBuddy/api/getEventsXML.php?sp_ID=2"]; where sp_ID can be 1,2,3,4 etc. how can i do it?? plz help me out?

+7  A: 

You can use the method [NSString stringWithFormat:@""] to format your URL string. For example,

NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://e.com/?var=%d", 2]];

If you look in the documentation for string format specifiers you can find out exactly what characters to use for each type of replacement (integer, double, object, etc).

Marc Charbonneau
thank you so much, Its working