Creating helpers

Before starting with the program, let's add some code that will help us through the app development process. Add a new file called Helpers.swift and add a helper function to execute the code in the main queue.

import Foundation

func M(block: dispatch_block_t){
    dispatch_async(dispatch_get_main_queue(), block)
}

Note

If you prefer, you can implement the M function in different ways. Some people prefer using NSOperation and some of them prefer using alternative frameworks like Async (https://github.com/duemunk/Async). It is up to you to choose the way it will be implemented.

Now create a new file called Extensions.swift. Here, we are going to add a function to display errors to the user, as we've already seen in the previous chapter. ...

Get Swift 2 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.