Php 如何使用Objective c设置url中的变量值

Php 如何使用Objective c设置url中的变量值,php,objective-c,Php,Objective C,您好,我正在尝试在objective c中设置php文件的变量值。当我把url放在浏览器中时,它就工作了。但我想知道如何通过目标c设置变量。 我知道如何连接到objective c中的php文件。我相信这就是你设置变量的方式,但它不起作用。我认为这与变量的url中必须有引号有关。 例如: http://localhost/MyPhpStuff/stuff/write.php?name="testName"&username="testUsername"&password="tes

您好,我正在尝试在objective c中设置php文件的变量值。当我把url放在浏览器中时,它就工作了。但我想知道如何通过目标c设置变量。
我知道如何连接到objective c中的php文件。我相信这就是你设置变量的方式,但它不起作用。我认为这与变量的url中必须有引号有关。
例如:

http://localhost/MyPhpStuff/stuff/write.php?name="testName"&username="testUsername"&password="testPassword"


NSString *strURL = [NSString 
stringWithFormat:@"http://localhost/MyPhpStuff/stuff/write.php?name=%@"
,nameTextField.text, "&username=%@", userNameTextField.text, 
"&password=%@", passwordTextField.text];
试试这个

 NSString *strURL = [NSString stringWithFormat:@"http://localhost/MyPhpStuff/stuff/write.php?name=\"%@\"&username=\"%@\"&password=\"%@\"",nameTextField.text,userNameTextField.text,passwordTextField.text];

这对我不起作用,我想这是因为变量周围需要引号,如我问题中的示例所示。请尝试添加引号:
NSString*strURL=[NSString stringWithFormat:@”http://localhost/MyPhpStuff/stuff/write.php?name=\“%@\”用户名=\“%@\”密码=\“%@”,nameTextField.text,userNameTextField.text,passwordTextField.text]