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:
Today, we’ll finish our discussion of the benefits of using Objective-C blocks and Swift closures by writing code to define and use a closure in Swift 3. For the full background on this topic, please read my last post entitled “Make blocks (closures) your friend (Objective-C and Swift 3).” Let’s plunge into Swift 3:
Let’s talk about source/version control, why it’s so important, and how you can easily put all your iOS code under source/version control management (SCM). I’m going to show you the manual steps involved in putting your code into a Git SCM “repository” (repo) so you fully understand how source/version control works. Jump straight to the tutorial if you’re already familiar with the concept of source control. I can’t explain everything about SCM in one blog post, but I’ll get you started and provide many online resources for you to reference. Why am I using Git? Like it or not, Git has become the de facto standard in SCM systems, mainly because it “is a free and open source [and] distributed version control system.” I don’t buy into the “Git is easy to learn” argument. I find Git to be overly complicated, cryptic, and generally requiring more steps to accomplish source control tasks than say centralized SCM systems like TFS or Subversion/SVN. Git does have some advantages over other SCM products, and it even becomes quite efficacious once you pay your dues learning how to use it properly.
My latest iOS app, AirStitch, was accepted into Apple’s App Store today. I developed the app in Objective-C, targeting the iOS 9 SDK, using Xcode, following the requirements provided by BriTon Leap, Inc. The company is the world’s leading developer of custom embroidery design software. Download the app for free and enjoy. The app is a marvel of engineering.
App Transport Security (ATS) is enabled by default for apps linked against the iOS 9.0 or OS X v10.11 SDKs or later, as indicated by the default Boolean value of NO for the NSAllowsArbitraryLoads key. This key is at the root level of the NSAppTransportSecurity dictionary.
With ATS enabled, HTTP connections must use HTTPS (RFC 2818). Attempts to connect using insecure HTTP fail. ATS employs the Transport Layer Security (TLS) protocol version 1.2 (RFC 5246). For background on secure Internet connections, read HTTPS Server Trust Evaluation.
With the advent of iOS 9, Apple decided that developers should avoid accessing insecure, unencrypted clear text HTTP (http://) resources on the Internet. Today I’ll show you how to access HTTP sites/services in your apps. I’ll explain the special hoops that Apple wants you to jump through just to use HTTP — and help you keep your app from being rejected.
For Apple to assume that anything HTTP is dangerous is a bit overboard as there are legitimate reasons to access a resource via clear text, like downloading an image (clear binary). Grabbing an image won’t reveal information about users’ private lives. A web/REST service that consumes someone’s name and Social Security number is a different story — that info must be encrypted.
Fortunately, Apple has made some accommodations in allowing continued use of HTTP as long as you provide “justification” when submitting your apps.
UPDATE: I’ve updated this article for Swift 4, learned a few new tricks, and taken advantage of the Swift 4 compiler’s “intelligence.” Please check out the new version as it’s more comprehensive and detailed, and my source code has been highlighted and commented to better help you understand the sometimes confusing concept of parallelism. There’s a brand new Xcode companion project, too.
I use concurrency in most of my iOS apps, generally to keep the user interface responsive. For those of you new to iOS and/or new to computer science, “Concurrency is the notion of multiple things happening at the same time.” (We can discuss the old “What’s the difference between concurrency and parallelism?” question later.) I’m constantly being asked questions about how to implement concurrency in iOS and, most recently, I’ve received many questions about how to implement it in Swift 3. Here’s a video showing this post’s concurrent Swift code running — and notice that a UIProgressView is updating while images are downloading in the background; notice also that I’m continually pressing a button that increments an instance variable during background processing:
The questions about implementing GCD in Swift 3 have come from beginners to intermediate- to even advanced-level developers. For years, the most widely used iOS construct for concurrency — “starting tasks asynchronously” — has been Grand Central Dispatch (GCD). Most iOS old-timers like me have gotten used to GCD’s Objective-C language version of the “dispatch_async” function:
How many times have you been looking at Swift or Objective-C code in Xcode and can’t remember what a framework method, argument, constant, etc. means? Did you know that help — full documentation — is just a keystroke away? Did you also know that you can add the same type of pop-up, context-sensitive help to your own code? Here’s how. Let’s say you’re looking at the following NSString class method and can’t remember exactly what the call does, what parameters it takes, and what is its return value:
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):”