Error Handling in Swift
May 5, 2016, 9:01 AM
Ideally, errors should never occur. File we need should always be available and networks should always be present and reliable. Unfortunately this reality is not ideal and we have to deal with the consequences. Thankfully the Swift team...
Creating and Modifying a URL in your Swift App
Mar 17, 2016, 4:36 PM
In many types of apps, you have to access files. They can be in your app bundle, on the file system, or even somewhere on the web. You need to have someway to refer to where they are in your code. On Apple platforms, you basically have...
Watch Connectivity in Swift — Application Context
Feb 16, 2016, 3:43 PM
In the age of watchOS 1, the watchKit extension was on the paired iOS device, making sharing data between it and the main iOS app easy. For the simplest of data, like preferences, we could just use NSUserDefaults with App Groups...
watchOS Hello World App in Swift
Dec 8, 2015, 9:30 AM
I have been working on some watchOS updates lately, and thought it would be helpful to share a bit about that. First things first, we need to actually know how to make a watchOS app in the first place. It’s time to do “Hello...
API Availability Checking in Swift
Jul 13, 2015, 9:39 AM
With all of the new and awesome APIs that come out every year for each successive iOS version, it can be tempting to just drop support for the previous versions of iOS, and just go completely to the new stuff. Of course though, we usually...
Protocol Extensions in Swift
Jul 7, 2015, 12:54 PM
So, if you’re using a class, structure, or enumeration which did not provide a method that would be very helpful for your app, you could simply add it via an extension (which you can read more about in the posts Swift Extensions Part...
Println Is Now Print, and Do-while Is Now Repeat-While in Swift
Jun 25, 2015, 12:49 PM
There are a few differences from Swift 2 that probably don’t need their own post, but should be mentioned nonetheless because they do have significant implications. This post will cover a few of those changes: Print replacing...
The Guard Statement in Swift
Jun 17, 2015, 8:11 AM
Often when working with Swift Optionals, we will want to perform an action if the Optional contains a value, or do something else if it does not. This is done with Optional Binding with the “if let” syntax, which lets us test...
Pattern Matching in Swift
Apr 29, 2015, 8:31 AM
Pattern matching is a staple of functional languages. At its core, Swift is primarily an object-oriented language, like Objective-C is. However, there are many advantages to the way more functional style languages like Haskell and Erlang...
Choosing Images with UIImagePickerController in Swift
Apr 27, 2015, 4:35 PM
If your Swift iOS app needs to import a picture from the user’s device, you’ve come to the right place today. Let’s learn how to use UIImagePickerController to let the user select a photo from their device to load into...
Integers and Numeric Literals in Swift
Feb 28, 2015, 11:43 AM
Numbers are the building blocks of any piece of software. It eventually gets all the way down to our code being translated into a series of numbers that refer to specific CPU instructions and data to use with them. We will stay well...
Swift Set Type
Feb 19, 2015, 1:43 PM
In Objective-C there were three basic types of Data Structures, NSArray, NSDictionary, and NSSet. In Objective-C, the immutable and mutable forms were separate, so you also had NSMutableArray, NSMutableDictionary, and NSMutableSet....
Multiple Optional Bindings in Swift
Feb 11, 2015, 12:36 PM
Shortly after my last post Segue from UITableViewCell Taps in Swift, Apple released Xcode 6.3 Beta 1, which includes Swift 1.2. There are many updates to the language that I was quite happy about, but let’s talk about my favorite...
Segue from UITableViewCell Taps in Swift
Feb 9, 2015, 1:20 PM
In many apps that use a UITableView, when a UITableViewCell is tapped, the screen will segue over to another view, such as how choosing a song in the Music app goes to the Now Playing screen, and plays that song, shows the album art, and...
How to Dismiss UITextField’s Keyboard in your Swift App
Jan 28, 2015, 12:01 PM
If you need to take text input in your Swift app, you will probably need a UITextField. It is exactly what it sounds like, just a field on the screen where the user types something in. When the user taps on it, the keyboard comes up from...
Getting Started With UITableView in Swift
Jan 26, 2015, 1:33 PM
One of the most common Views used in iOS apps is the UITableView. In the default iPhone apps alone, the only ones that I didn’t easily find what is PROBABLY a UITableView was in Newsstand, Videos, Camera, and the Calculator. Even...
How to Create a UIColor in Swift
Jan 15, 2015, 1:13 PM
There comes a time in many iOS developers’s careers that they will need to save a reference to a color itself. Maybe it is just to change the background color of a view, maybe it is for custom drawing, or any number of other...
Segue between Swift View Controllers
Jan 13, 2015, 9:30 AM
So, last time we learned how to make a simple Hello World app on a single view controller. As fancy as it was, you probably want more than one screen in your app, right? Perhaps you want a way to segue into the next screen? That’s...
Hello World! Your first iOS App in Swift
Jan 6, 2015, 9:31 AM
So far we’ve covered a lot of how Swift the language works, some WatchKit tutorials, and how to get started with some Cocoa classes. However, we have not really done much in the way of actually writing sample apps on the Coding...
Swiftly getting a human-readable date with NSDateFormatter
Dec 22, 2014, 9:30 AM
Now that we know a bit about Date and DateComponents, let’s actually get a readable date in our Swift app, shall we? This is the job of DateFormatter. DateFormatter is a class that can take a Date, and output a String describing...
NSUserDefaults — A Swift Introduction
Dec 17, 2014, 9:30 AM
So, let’s say we have an app that needs to remember a few simple things that the user puts in when they first load the app. It needs to remember the user’s name and birthday, to show on some view controller, or maybe even for...
Custom Operators in Swift
Dec 9, 2014, 3:55 PM
You have been spared the terrible pun for this title, I knew the last one was trouble when it was typed in. So, in the earlier article Operator Overloading — Tailor Swift To Your Needs, you saw how you could add functionality to already...
DateComponents — Class Reference
Nov 14, 2014, 10:30 AM
As mentioned last time in my post Date — Class Reference, now we go a bit more in depth with DateComponents. In my opinion, this is the real powerhouse for dealing with time in Swift or Objective-C. When I was first learning iOS, I...
Date — Class Reference
Nov 12, 2014, 4:41 PM
An NSDate object specifies a particular point in time. Despite “date” being in its name, it really stores time, of which the date is a component. Under the hood, NSDates (as far as the public superclass we can see is...
Add sharing to your Swift app via UIActivityViewController
Nov 10, 2014, 10:34 AM
In several iOS apps, such as Safari or the Camera app, you can click a button that brings up an interface that makes it easy to send or share what you are looking at via messages, Twitter, Facebook, etc. That interface is known as the...
Execution States for a Swift iOS App
Oct 31, 2014, 11:07 AM
Time to start moving away from pure Swift posts, and start talking about making iOS apps. Though we will be talking about doing so with Swift, of course. Today we are going to talk about the Five Execution states of an iOS app. The iOS...
Generic Types in Swift
Oct 28, 2014, 3:34 PM
We have previously discussed generic functions on this blog in the post Generic Functions in Swift. There is one more aspect to generics in Swift that we have not covered yet, Generic types. Generic types let you write a named type...
Operator Overloading — Tailor Swift To Your Needs
Oct 13, 2014, 2:35 PM
Sorry, but I have been waiting for months to make this pun. So today, we are going to talk about Operator overloading in Swift. This tool is very useful, but quite dangerous as well. The “With great power comes great...
Structures in Swift
Oct 9, 2014, 2:19 PM
We’ve so far looked at 2 of the 3 named types in Swift with their own dedicated posts. First was Enumerations in Swift, and later was Classes In Swift — An Introduction. Now we finally talk about the third one, Structures. Swift...
Tuples in Swift: Create, Read, and Return
Oct 6, 2014, 10:05 AM
I was looking for a bit of information on Tuples in Swift for an app I was working on, and decided it would be best to gather what I learn into one, easy to access place. Tuples are a compound type in Swift, which basically means that they...
Swift Extensions Part 2 — Nested Types, Subscripts, Protocols
Oct 2, 2014, 10:30 AM
Welcome to part 2 of the Swift Extensions posts. If you haven’t already, check out the previous post Swift Extensions Part 1 — Computed Properties and Initializers, to learn about those aspects and get an introduction to what Swift...
Swift Extensions Part 1 — Computed Properties and Initializers
Sep 29, 2014, 2:59 PM
So, there has been a reason for my most recent choice of topics to discuss. This isn’t some grand culmination post, but the topic for today is related to several of the previous topics due to what it can do. Back in Objective-C,...