如何解决如何为WebService连接ASIHTTPRequest
| 我是iphone的新手。...当我需要连接到其中一个Web服务时,我正在使用下面的代码tat正在使用ASIHTTP请求..当我添加此代码时,它将出现错误 我正在使用UIViewController类在未声明的ASIHTTPRequest中先声明它,然后在我声明的位置和我声明的位置? 我怎么声明?我可以做什么?请建议我 代码如下-(void)callWebService
{
//this is a typical url for REST webservice,where you can specify the method that you want to call and the parameters directly with GET
NSURL *url = [NSURL URLWithString:@\"http://www.yourserver.net/webservice/rest/?method=myMethod&par1=ok\"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDidFinishSelector:@selector(requestCompleted:)];
[request setDidFailSelector:@selector(requestError:)];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestCompleted:(ASIHTTPRequest *)request
{
Nsstring *responseString = [request responseString];
}
- (void)requestError:(ASIHTTPRequest *)request
{
NSError *error = [request error];
}
感谢你...
解决方法
首先检查您的项目中是否附加了asihttp软件包。
在那之后你有
#import \"ASIHTTPRequest.h\"
将此导入到您的视图控制器中
不要忘记检查您是否已附加以下框架。 CFNetwork,SystemConfiguration,MobileCoreServices,CoreGraphics和libz框架。
您尚未确定使用哪种方法
[request setRequestMethod:@\"GET\"]; BEFORE [request startAsynchronous];
当您右键单击Framework文件夹时,将显示此弹出窗口。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。