Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Concurrency on iOS Made Simple: Sync-Async Pair Pattern

DZone's Guide to

Concurrency on iOS Made Simple: Sync-Async Pair Pattern

· Mobile Zone ·
Free Resource
So no doubt you implement some kind of asynchronous operation pretty often in your code, and chances are like us you do it fairly haphazardly. Here’s a post about adding a little formality to that design:

 

Sync-Async Pair Pattern – Easy concurrency on iOS

Apple provides many tools for implementing concurrency in your application. NSOperationQueue, GCD, or simply using performSelectorInBackground:withObject: that is available on each and every object, are just some examples. The tools are there, yet implementing good concurrency is hard.

The solution I have found is not yet another tool, or framework, but a simple pattern. I have not found an existing name for the pattern so I call it Sync-Async Pair. The idea is to hide the complexity of asynchronous calls and call-back behind a facade, and have a straightforward synchronous implementation. An implementation that is easy to write, test and extend…


Definitely worth a read!

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}