how do I remove/release added NSInvocationOperation from NSOperationQueue after completion of downloading a video?
The operation is automatically removed from the queue when it has finished i.e. when -isFinished returns true.
And also, what should I do if in case I want to stop to download specific video while the process of downloading in progress?
When you want to stop an operation part way through, you must send it the -cancel message. However this will not magically stop the operation from running. Your task needs to periodically check if it is cancelled and finish itself if it turns out that it has been. So you need to download your video in chunks and check the operation's cancelled status after each chunk. The following pseudocode might help:
while (![myOperation isCancelled] && thereIsMoreData)
{
download a chunk of data and save it
}
This means, for instance, you can't use NSURLConnection
's -sendSynchronousRequest:returningResponse:error:
to get the data because it won't be able to check the cancelled status of the operation until after all the data is already downloaded.