开发者

how to connectASIHTTPRequest for WebService

开发者 https://www.devze.com 2023-03-13 00:58 出处:网络
i am new to iphone....when i need to connect to one of the web service i am using follwing code tat is using ASIHTTP request..when i add this code its coming error

i am new to iphone....when i need to connect to one of the web service i am using follwing code tat is using ASIHTTP request..when i add this code its coming error

ASIHTTPRequest is undeclared declare it first where i shd declare and wat i shd declare?i am using UIViewCon开发者_如何学运维troller class

how i shd declare? wat i shd do?plz suggest me the code is given below

-(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];

}

thank u...


First check that you have asihttp package attached in your project. After that check you have

#import "ASIHTTPRequest.h" import this in your viewcontroller

Dont forget to check that you have attached the following frameworks. CFNetwork, SystemConfiguration, MobileCoreServices, CoreGraphics and libz framework.

You have not tell which method to use

[request setRequestMethod:@"GET"]; BEFORE  [request startAsynchronous];

When you will right click on framework folder this popup will appear.

how to connectASIHTTPRequest for WebService

how to connectASIHTTPRequest for WebService

0

精彩评论

暂无评论...
验证码 换一张
取 消