Does someone know a way to remove requests from an ASINetworkQueue in a persistent way? The reset function doesn’t seem to do the job. What I’m trying to do is the following
- (void)fillAndRunQueue:(ASINetworkQueue*)queue requests:(NSArray*)requests {
for (ASIHTTPRequest* request in requests) {
if ([request check]) { // Valid request => add it to the queue
[queue addOperation:request];
} else { // Invalid request => cancel immediatelly
// HOW TO REMOVE ALL PREVIOUS REQUESTS FROM THE QUEUE??
return;
}
}
[queue go];
}
The two obvious options I can see are:
or if you want more control:
for each request you want to “remove” (this isn’t technically removing them, but may have a close enough effect for your purposes).
Although, I think
[queue reset];should also work – maybe you can explain exactly what happens when you try to use it?If all else fails, releasing and then recreating the queue should remove everything.
Update
To further explain, I don’t think it’s possible to actually remove items from an NSOperationQueue, only to cancel them. (ASINetworkQueue is a subclass of NSOperationQueue.)
The apple docs are here:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html