Search code examples
iosnsurl

Post url for a registration app


I tried to insert some text from some string variables from a text field and the following error is shown.

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

This is the code that I have Used.

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];

Is there some other format to enter extra text from the string variables shown?


Solution

  • You should use NSString stringWithFormat like shown below

    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 ]];
    

    One more thing, use naming convention like registerUrl instead of Registerurl