在我的代码中,我试图将一些数据发送到我的 PHP 文件
为了将内容添加到我的 SQL 中,我使用 GET 方法。
到目前为止,我需要在网站上使用一个表单,但我想通过浏览它来添加数据,例如:
http://server.com/add.php?user=some data here&message=最后的数据在这里
到目前为止,我正在尝试使用这段代码:
NSURL *add = [NSURL URLWithString:@"http://server.com/ios/add.php?user=iPhone App&message=%@",
messageBox.text];
[messageView loadRequest:[NSURLRequest requestWithURL:add]];
但是 Xcode 告诉我:“方法调用的参数太多,预期 1,有 2”
最佳答案
试试这个
NSString *urlString = @"http://server.com/ios/add.php?user=iPhone App&message=";
NSString *escapedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *add = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",escapedString, messageBox.text]];
[messageView loadRequest:[NSURLRequest requestWithURL:add]];
你应该使用 NSString +stringWithFormat:
关于php - iOS Xcode NSURL 参数太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12954866/