September 30, 2018 | Swift, Networking, Unit Testing, iOS, macOS, tvOS, watchOS
We write asynchronous code when we know a task will take time to complete, whether because it's computationally expensive or we're making a network request. Testing this code can be difficult, especially when the asynchronous logic is internal. For example, let's say we're making a fire and forget request to load an image into an image view? We would likely make the request on a background queue and . . .
September 30, 2018 | Swift, iOS, macOS, tvOS, watchOS
Key paths were introduced in Swift 4 and allow you to reference a type's properties without evaluating them. In this tutorial, we'll use key paths to write a generic array extension that makes sorting more convenient with code that is easier to read.
September 8, 2018 | Swift, Control Flow, iOS, macOS, tvOS, watchOS
One thing that bothers many developers about using if statements for type checking in Objective-C is that it suggests a specific order of importance. For example, here's how you might use type checking in an Objective-C `prepareForSegue` method. This Swift version is much more concise, but we still have . . .
August 11, 2018 | Swift, Alamofire, Networking, iOS, macOS
In Part 1 of this tutorial, I explained how to use the Alamofire and AlamofireImage libraries to asynchronously download and cache images to be displayed in a UICollectionView. At the end of that project, we still had a performance problem. UIImage by default waits until right before display to decode . . .
August 11, 2018 | Swift, Alamofire, Networking, iOS, macOS
Downloading and caching images are common tasks in iOS development, especially when using collection and table views. In this tutorial, we're going to use the popular Swift networking library Alamofire and its companion image library AlamofireImage to build an app that displays images of Glacier National Park.