tags:

views:

156

answers:

2

Hello everyone

I have a project using ASIHTTP to multi download files from a site

when I add a new request:

[networkQueue cancelAllOperations];
[networkQueue  setDownloadProgressDelegate:a];
[networkQueue  setDelegate:self];
[networkQueue   setRequestDidFinishSelector:@selector(requestDone:)];

NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
[networkQueue  addOperation:request];

[networkQueue  go];

it reported:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[ASINetworkQueue addOperation:]: operation is executing and cannot be enqueued'

It looks like I can not add a new request when others are running.

Welcome any comment

Thanks

interdev

+2  A: 

If you are using a network queue, you cannot start the operation before you enqueue it. Don't call startAsynchrnous, just enqueue the operation and the network queue will start it when it dequeues it. Pretty much exactly what your error message says ;)

Jason Coco
A: 

just remove the [request startAsynchronous]; and it will work fine for you.

hope this helps.

Thanks.

Madhup