7 posts with this tag

Building a networking layer with operations

October 03, 2018

Networking is central to how most apps add value to their users which is why significant effort has been put into creating an easy to use networking layer by both Apple and the open-source community. When iOS was first released, NSURLConnection was the native networking suite it shipped with. However the NSURLConnection story actually began long before iOS as it was first released in 2003 with Safari, this meant that NSURLConnection was never designed for the magnitude of tasks that it ended up having to s…

Avoid queue jumping

April 17, 2017

We are often told that no matter where we end up, we shouldn't forget where we came from. Usually, this applies to people, but it can also apply to code. Specifically, code that runs on a different queue from the queue it was scheduled on. queue-jumping 🦘 It's not unusual to see queue-jumping throughout a project: DispatchQueue.main.async { in //Update UI } Even with the syntax improvements of using GCD introduced in Swift 3, having these GCD calls littered in our code acts as an interruption to it…

Coalescing Operations - Take 2

September 07, 2016

In "Coalescing NSOperations" I wrote about coalescing NSOperations however, during the writing of that article, I began to explore other ways that I could coalesce operations. One solution I discovered has all the benefits of the previous coalescing approach but significantly reduces the amount of effort required by the developer to support coalescing. This new approach is the topic of this post. Take 2 📽 In "Networking with NSOperation as your wingman" I wrote about combining NSURLSes…

Coalescing Operations

August 28, 2016

This post is now outdated, please instead check out my newer post on Coalescing Operations for my latest solution to coalescing operations - I'm leaving this here in case anyone needs it. In "Networking with NSOperation as your wingman" I wrote about combining NSURLSession with NSOperation to wrap networking requests and the processing of that request into one single task. One advantage that came from this combining was it was possible to prevent duplicate network requests to the same resource…

Networking with NSOperation as your wingman

February 04, 2016

This post is based on an Objective-C example. If you are more interested in seeing how to combine networking and operations based on a Swift example, head over to the more recent "Building a networking layer with operations" post. The beautiful and maddening thing about programming is that there are so many ways to solve the same issue. Each solution has its own tradeoffs and as developers, it is up to us to choose the solution that has the most positives for our problem. Let's take networking…

Polling with NSOperation

May 16, 2011

Recently I was writing an application that analysed audio input and updated an audio visualiser on screen. Running everything in the main thread just ground UI responsiveness down so I decided to spin off the audio capture into a separate thread. My first thoughts where to use NSOperationInvocation and run across this tutorial by Wim Haanstra on how to keep a thread alive. This solution worked but the code that I had produced using it felt messy so I decided to experiment myself. NSOperation I decided to…