php – iOS Xcode NSURL参数太多了

前端之家收集整理的这篇文章主要介绍了php – iOS Xcode NSURL参数太多了前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的代码中,我试图将一些数据发送到我的 PHP文件

为了在我的sql添加东西,我使用GET方法.

到目前为止,我需要在网站上使用一个表单,但我想添加数据只需浏览它,例如:

这里有http://server.com/add.php?user=some个数据& 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:

@H_404_40@

猜你在找的Xcode相关文章