Remove KVO of progress in favor of using the NSURLSession delegate APIs by coreyfloyd · Pull Request #3607 · AFNetworking/AFNetworking
The impetus for this change was a bug related to: https://github.com/AFNetworking/AFNetworking/issues/3380 Which points to an issue where AFURLSessionManager could get in a state where it does not inform the AFURLSessionManagerTaskDelegate to un-observe cancelled (or otherwise completed) tasks before they are deallocated. While the above issue is specific to background tasks/sessions, we have observed it on sessions with default configurations as well. Instead of debugging the KVO issues, I decided to replace the KVO code with in favor of the appropriate NSURLSession delegate methods. Running all unit tests shows that this approach appears to be working. The pull request that made this change (AFNetworking#3187) mentions that its goal was to remove the need for AFNetworking API consumers to use a KVO API for getting progress. This makes sense, but I was unable to see any reason why KVO was used internally for getting progress information rather than the NSURLSession Delegate methods. Because of this, It isn't clear to me what the historical reasons were/are for KVO being needed to satisfy the progress requirements of the AFNetworking API. With any luck, KVO is no longer needed and we can eliminate this class of crashes by eliminating KVO.