How many of you use freeform drawing in Xcode playgrounds? How many of you understand how drawing in playgrounds work? Xcode playgrounds can serve as great tools for prototyping your in-development apps, whether it be experimenting with algorithms or toying with ideas for app user interfaces. Granted that drawing in playgrounds is not that well documented. So the subject of this tutorial is how drawing in Xcode playgrounds works and a good number of pointers to help you start drawing in playgrounds. Here’s an example of what I’m talking about:
Category: UIKit
Tutorial: delegates and delegation in Objective-C
[Download Xcode 9 project with full Objective-C source from GitHub.]
Introduction
I’m going to talk about “delegates” and “delegation.” I’ll lead you through a simple example of implementing the delegation design pattern in Objective-C, with full source code, and then show you a more sophisticated scenario. My intent here is to show you how delegation works without getting bogged down in some crazy complex example. Download the Xcode 9 project with full Objective-C source from GitHub to follow along.
I’ll show you how to build a user interface (UI) component, a status/progress indicator, which you can display on screen for processing-intensive tasks… AND I’ll show you how you can customize the behavior of the indicator by using delegation. For example, when the indicator starts, you could disable your UI; when the indicator stops, you could re-enable your UI; and, when the user taps the indicator, you could cancel processing-intensive tasks. Here’s the app we’ll build:
Continue reading “Tutorial: delegates and delegation in Objective-C”
Fix for IBOutlet, IBAction connections disappearing in Xcode 9
You’ve been working on your billion dollar app happily for days or weeks. It’s Monday morning, you open up Xcode 9 to get back to work and — dang, bummer — all your
IBOutlet
and IBAction
connections look like they’ve been disconnected (see image below):
Continue reading “Fix for IBOutlet, IBAction connections disappearing in Xcode 9”
Polymorphism in Swift 3: manipulate multiple related controls with one IBOutlet and one IBAction
- [Download Xcode 8.2.1 project with full Swift 3 source from GitHub.]
- [Download Xcode 8.2.1 playground with full Swift 3 source from GitHub.]
How would you enable or disable multiple user interface controls using one IBOutlet and one IBAction? For example, you might need to disable a UITextBox and UISegmentedControl because a user’s login has expired. Perhaps a user hasn’t filled in some required fields on a form, so you want to disable several buttons. Watch the following video to see how I built a Swift 3 app to use a UISwitch to enable or disable four controls all at one time — and I demonstrated the object-oriented programming (OOP) principle of polymorphism:
Refresh your memory about OOP and inheritance.
Intro to object-oriented principles in Swift 3 via a message box class hierarchy
[Download Xcode 8.2.1 project with full Swift 3 source from GitHub.]
Let’s talk about using Swift 3’s object-oriented programming (OOP) features to make you a better developer. First, we’ll get a quick overview of the sample project for this post. Second, we’ll discuss the advantages of OOP in Swift. Third, we’ll talk about OOP in depth. Fourth, let’s think about how all the OOP theory applies to my code. Fifth, we’ll specify the Swift 3 syntax required for defining classes and creating instances (objects) of those classes. Finally, we’ll go through my Swift source code to implement a useful OOP class hierarchy (which you are free to include in your own projects subject to my terms of usage). Hey! Check out my latest post on polymorphism, a natural continuation of this article.
Continue reading “Intro to object-oriented principles in Swift 3 via a message box class hierarchy”
Swift 3 segues, unwind segues, storyboards, and view/navigation controllers
[Download Xcode 8.2.1 project with full Swift 3 source from GitHub.]
Today’s tutorial covers transitions — segues — from one source storyboard scene to another destination scene, and unwind segues leading back from destination to source… I created a project to help you follow along with this tutorial, written in Swift 3, against the iOS 10 SDK, and using the Xcode 8.2.1 IDE. Please download the project. The app produced by the project is shown in action in the following video. Please watch before continuing on:
Segues don’t exist in a vacuum. I’ve introduced a UINavigationController into the mix. Of course, you’ll see a few UIViewControllers. I’ve also used a UITableView and managed its complexity by breaking it into logical pieces by using Swift “extensions.” As you proceed, you’ll have to grasp concepts like Auto Layout and managing a table view’s data source.
Continue reading “Swift 3 segues, unwind segues, storyboards, and view/navigation controllers”
Using Swift extensions to manage complexity, improve readability, and increase extensibility (UICollectionView, protocols, and delegates)
[Download the full Xcode project from GitHub.]
Today, I’m going to show you how to leverage the Swift “extension” language feature to manage software complexity, improve code readability, and increase extensibility. We’ll also talk about delegates, data sources, and protocols as they are concepts essential to this tutorial. According to Apple’s “The Swift Programming Language (Swift 3.0.1):”
UPDATE: The UICollectionView is much more than a grid or matrix
Get started by [downloading the full Xcode project from GitHub.]
Let’s talk about the UICollectionView, a rich, configurable, and powerful iOS user interface component. I will write code in Swift 3.0 to create a UICollectionView to which I can add, select/highlight, deselect/unhighlight, and remove UICollectionViewCell’s. I’ll show you that I can select, deselect, add, and remove one cell at a time, or multiple cells at a time. And most importantly, I’ll demonstrate the importance of the relationship between a UICollectionView and its data source, and the importance of keeping a UICollectionView and its data source synchronized. You can download my entire Xcode 8.2.1 project. Feel free to reuse my code as long as you follow the terms of the license agreement. Today, we’re going to build a basic but completely functional instance of the UICollectionView in Swift 3.0 as illustrated by the following video:
Continue reading “UPDATE: The UICollectionView is much more than a grid or matrix”
iOS 101 or … Basic animation, Auto Layout, and view geometry – Part 5
[Download the full Xcode project from GitHub.]
Today, I’m going answer all the questions I posed in this series of posts entitled “Basic animation, Auto Layout, and view geometry – Part X” (see parts 1, 2, 3, and 4). I’ll help you understand how how I created the following iPhone animation using Swift 3.0 — and/or how to get started with your first iOS app:
Continue reading “iOS 101 or … Basic animation, Auto Layout, and view geometry – Part 5”