0

我试图从文本字段的一些字符串变量中插入一些文本,并显示以下错误。

Too many arguments to method call, expected 1, have 9

这是我使用的代码。

NSURL *Registerurl;
Registerurl= [[NSURL alloc]initWithString:@"http://xfgfgx.php?first_name=%@&last_name=%@&email=%@&password=%@&address_1=%@&address_2=%@&city=%@&state=%@&zip=%@&action=signup",regisrationdetails.firstname,regisrationdetails.lastname,regisrationdetails.email,regisrationdetails.address1,regisrationdetails.address2,regisrationdetails.city,regisrationdetails.state,regisrationdetails.zip];

是否有其他格式可以从显示的字符串变量中输入额外的文本?

4

1 回答 1

5

您应该使用NSString stringWithFormat如下所示

NSURL *Registerurl;
Registerurl= [[NSURL alloc]initWithString:[NSString stringWithFormat:@"http://xfgfgx.php?first_name=%@&last_name=%@&email=%@&password=%@&address_1=%@&address_2=%@&city=%@&state=%@&zip=%@&action=signup",regisrationdetails.firstname,regisrationdetails.lastname,regisrationdetails.email,regisrationdetails.address1,regisrationdetails.address2,regisrationdetails.city,regisrationdetails.state,regisrationdetails.zip ]];

还有一件事,使用registerUrl之类的命名约定而不是Registerurl

于 2013-10-28T09:13:12.117 回答