php – iOS Xcode NSURL参数太多了
发布时间:2020-12-14 17:21:48 所属栏目:百科 来源:网络整理
导读:在我的代码中,我试图将一些数据发送到我的 PHP文件 为了在我的SQL中添加东西,我使用GET方法. 到目前为止,我需要在网站上使用一个表单,但我想添加数据只需浏览它,例如: 这里有http://server.com/add.php?user=some个数据 message =这里的最后数据 我到目前为
在我的代码中,我试图将一些数据发送到我的
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: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |