views:

357

answers:

1

Hi all ,

I am using ASIHTTPRequest to fetch some data from a web service.

I am making requests using a loop.

The problem is that it doesn't seem the request is going asynchronously so that my activityindicator is not working .

Is it true that ASIHTTPRequest is not asynchronous .

or should i use the regular nsmutablerequest to perform asynchronous request .

+1  A: 

You should put your request in a download queue, i.e.

ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[queue addOperation:request];
[request release];    

Just

[request startAsynchronous]; 

runs the request on the UI thread, so you should try it with download queue.

Henrik P. Hessel
the nsoperation line is giving error saying that the sharedAppDelegate method will not respond to the MyAppDelegate. and the line [request startAsynnchronous] is also giving the same warning .
hib
yap, because is just an example.. wait a minute
Henrik P. Hessel
edited the answer. [request startAsynchronous] doesn't belong to the first code snippet.
Henrik P. Hessel
ok so basically i am given the mehthod [request start]; is it ok .
hib
http://allseeing-i.com/ASIHTTPRequest/How-to-use check the examples :)
Henrik P. Hessel
ok works . thanks for your patience and support.
hib
startAsynchronous cannot be found in the class header, and it gives a warning.The operation queue is something I banged my head on the wall for a long time until I thought of it.
natanavra
seems that startAsynchronous isn't longer supported. Strange, the documentation still mention it.
Henrik P. Hessel
startAsynchronous is absolutely still supported - I'm surprised it isn't showing up in the header for you. The behaviour has changed in the latest version (1.5 as time of writing) - requests started with startAsynchronous now run in thread they were started from, rather than in a global operation queue.startAsynchronous won't update the network activity indicator for you, though it should be trivial to do that yourself. Or, use a queue, as Henrik recommended :)
pokeb