如何为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文件夹时,将显示此弹出窗口。