Saturday, 15 June 2013

ios - How do I add a number to an NSURL? Too many arguments error -



ios - How do I add a number to an NSURL? Too many arguments error -

i've got little problem seems little bit odd me. used nsstring or nslog while adding nsnumbers several places:

nsnumber *categoryid = [[nsnumber alloc]initwithint:0]; nsurl *url = [nsurl urlwithstring:@"http://shop.rs/api/json.php?action=getcategorybycategory&category=%i",[categoryid integervalue]];

now xcode tells me i'm many arguments. doing wrong? setting nsnumber nsstrings or nslogs works did above.

best regards

what wrong on

nsurl *url = [nsurl urlwithstring:@"http://shop.rs/api/json.php?action=getcategorybycategory&category=%i",[categoryid integervalue]];

you calling urlwithstring: , pass in string not beingness formatted correctly. if want on 1 line need using stringwithformat:

nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:@"http://shop.rs/api/json.php?action=getcategorybycategory&category=%i",[categoryid integervalue]]];

because adding parameter can't create string @"some text" need format using stringwithformat: homecoming nsstring * text held within @"" , paramters pass in. [nsstring stringwithformat:@"my string come %@", @"apples"]; provide nsstring "my string come apples". more info check out apple documentation nsstring , stringwithformat:

ios objective-c nsurl

No comments:

Post a Comment