A Modern Network Operation
When Apple introduced the NSURLSession
API, the landscape of network operations changed. In some ways, the new API made things worse as the block API that was added tempts developers to become very sloppy with network calls. The block API makes it trivial to add network calls anywhere in an application. Very little thought or structure is required. From this (and some third party libraries who followed the same pattern) we have seen an explosion of increasingly poor network handling in applications.
For my own purposes I have resisted this slippery slope as often as possible. However I still preferred the way NSURLConnection
worked and how it integrated nicely with NSOperation
subclasses. My attempts at using the NSURLSession
were cumbersome and didn’t feel “right”.
Fortunately, I have recently worked on a design that I have been quite pleased with. In this design I am happily using NSOperation
subclasses again and I am using the NSURLSession
API.
(more…)