Category: Tutorial

Use Sets in Swift

Of the most underrated collection types is sets. Sets are an unordered collection with unique values. Let’s take a look at what you can do with sets.  Download the exercise files and you’ll find I created  playground with a Struct called Pizza. I’ve made…

Launch an Alert from a Closure Safely

Your app can get into problems when you launch UI from others threads, such as closures.  For example, you  might have an app that going to ask for permissions for things like photos, notifications, or location data. The system usually handles those, but you…

Change UIColors to RGB and HSB colors

One dilemma you’ll find when working with colors is switching between color systems. There’s two you’ll most often be using: the Red-Green-Blue or RGB and Hue-Saturation-Brightness or HSB. Download the Exercise file and run. It will give you the HSB value, but what if…

Use Dynamic Type

For reading ease and visual accessibility you should be using dynamic fonts whenever possible. Let’s look at an example you can get from the download files. I’ve run the Split View Controller from a previous tip in landscape on an iPad Pro 9.7 inch….

Programmaticall​y Add Split View Controllers

An often ignored but rather powerful View Controller is the UISplitViewController. You can make one from a template and the storyboard, but I often skip both and do it programmatically, which is especially good when I’m prototyping in a playground.  Let’s give it a…

Refactoring

One of the core elements of clean code is having code that is consistent with identifiers. Head to the AppDelegate. Take a look at this code from the tip from last week. I have a few problems with it. I’m not being very consistent…

Understand Closures

You’ll find closures throughout the API’s, but you may not know how to use them properly. Let’s take a basic tour of closures.  Download the exercise file, and you’ll find a project with a playground. In the playground you’ll find a function  to compute…

Ducking Sound in AVAudioSession

title shot

Ducking has nothing to do with waterfowl. Sometimes you’ll want to add sound to your app, but the user will be using the music or others app along with your app.  For that, you’ll want to slightly lower the volume of the background music…

Actions in Table Views

Sometimes table views could use a few buttons. There’s two delegates which create swipe buttons on table view cells. Let’s learn how you can implement these buttons and an interesting hidden feature you can do with them.  There is two delegate methods, one for…

Thrown Errors

There’s many ways to handle errors in Swift. For some errors, using throws is a great way to handle errors without crashing the system. Download the exercise file. You’ll find a project with an embedded playground.  While there’s a lot better ways to do…