How to Create a Synchronous Wrapper Around an Asynchronous Method

Wrapper Asynchronous methods are the key to keeping your iOS app responsive. Each method running on the main thread has 1/60 of a second to return before it will affect your screen refresh rate. For long-running operations, the typical paradigm is to execute your code on a separate thread (via an abstraction such as dispatch_queue_t or NSOperationQueue), and when it completes, to invoke a completion handler on the main thread. That way the main thread is available to process touch inputs or render UI elements.

Continue reading

Advertisements

How to Accept Multiple Enum Values in a Property or Method

enum

Every iOS developer has probably come across a property or method in an API that accepts multiple enum values at once, separated by a vertical pipe. How does that work, and how can we do the same?

Continue reading

Why Static Code is Bad

static

Most object-oriented developers are familiar with static methods and classes. They are present in most programming languages including C# and Objective-C (where they are known as class methods). Here are some common cases in which they are used: Continue reading