AFNetworking/AFNetworking — pull request #1662 by sampage (2013-12-04 06:02:28+00:00)
Title: Afurl connection operation is finished without being started fix

Fix for

```"AFHTTPRequestOperation 0x7fed650039b0 went isFinished=YES without being started by the queue it is in"```

Crash occurs primarily (perhaps exclusively) on iOS 6.1 when an NSOperation (in this case AFHTTPRequestOperation) is queued in an NSOperationQueue and cancelled before the operation has started. This can occur when using the UIImageView+AFNetworking category and setting the URL on the same UIImageView in quick succession.

Changes include the majority of cancelling logic out of -cancel and into -start where if -isCancelled is YES, the state is set to finished and the -cancelConnection is called, else the existing logic of checking -isReady and performing the duties of the operation.

This change is designed to mirror the default implementation of NSOperation according to the 7.0 docs

>The default implementation of NSOperation does include checks for cancellation. For example, if you cancel an operation before its start method is called, the start method exits without starting the task.

Other changes include removing the -cancelled flag from AFURLConnectionOperation and associated KVO notifications, instead relying on the base implementation of -cancelled to try an adhere to the following from the 7.0 docs

>Support for cancellation is voluntary but encouraged and your own code should not have to send KVO notifications for this key path.