remove an ASIHTTPRequest thread when it is done
Posted
by user262325
on Stack Overflow
See other posts from Stack Overflow
or by user262325
Published on 2010-03-12T14:41:01Z
Indexed on
2010/03/12
14:47 UTC
Read the original article
Hit count: 463
iphone
Hello everyone
I have a project in which it runs 5 download threads
- (void)fetchThisURLFiveTimes:(NSURL *)url
{
[myProgressIndicator setProgress:0];
NSLog(@"Value: %f", [myProgressIndicator progress]);
[myQueue cancelAllOperations];
[myQueue setDownloadProgressDelegate:myProgressIndicator];
[myQueue setDelegate:self];
[myQueue setRequestDidFinishSelector:@selector(queueComplete:)];
int i;
for (i=0; i<5; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDelegate:self];
[myQueue addOperation:request];
}
[myQueue go];
}
- (void)requestWentDone:(ASIHTTPRequest *)request
{
//..
}
- (void)queueComplete:(ASINetworkQueue *)queue
{
NSLog(@"Value: %f", [myProgressIndicator progress]);
}
I hope to remove a thread when it is done. I do not know where I need to place my codes:
requestWentDone:(ASIHTTPRequest *)request
or
queueComplete:(ASINetworkQueue *)queue
I noticed there is no tag property for request, so I added it to ASIHTTPRequest to help me recognize which thread prompts the function reuqestWentDone,
I can get the tag of different request, but I do not know how to remove the ASIHTTPRequest thread from myQueue.
Welcome any comment
Thanks
interdev
© Stack Overflow or respective owner