一个字符串中的多个变量

mys*_*ola 1 objective-c nsstring

我目前有这段代码:

NSString *strURL = [NSString stringWithFormat:@"http://www.sample.com   /phpFile.php?firstname=%@",txtfirstName.text];

NSString *strURL2 = [NSString stringWithFormat:@"http://www.sample.com/phpFile.php?lastname=%@",txtlastName.text];
Run Code Online (Sandbox Code Playgroud)

但问题是,这会创建两个不同的行,我想要一行的名字,姓氏和其他所有内容.

那么可以这样做:

NSString *strURL = [NSString stringWithFormat:@"http://www.sample.com   /phpfile.php?firstname=%@",txtfirstName.text,txtlastName.text,txtheight.text,txtweight.text];
Run Code Online (Sandbox Code Playgroud)

还是我需要做一些更复杂的事情?

提前致谢!

day*_*v89 11

NSString *strURL = [NSString stringWithFormat:@"http://www.sample.com/phpfile.php?firstname=%@&txtlastName=%@&txtheight=%@&txtweight=%@",txtfirstName.text,txtlastName.text,txtheight.text,txtweight.text];
Run Code Online (Sandbox Code Playgroud)

使用它并喜欢这个