Aut lego vel scribo; doceo scrutorve sophian.
With the arrival of Swift 5 in early 2019, the stamp of maturity has been placed upon the Swift language. When Swift was introduced to the public in 2014, it was a sort of second-class citizen. The Cocoa frameworks that give an iOS app its functionality expect to be spoken to in Objective-C, and several megabytes of libraries had to be included in every Swift app, effectively containing the whole of the Swift language and translating everything into Objective-C. But Swift 5 introduces ABI stability, which means that, since iOS 12.2, the Swift language has become part of the system. Swift is now on a par with Objective-C, and Swift apps are smaller and faster.
Swift is the programming language used throughout this book. Still, some awareness of Objective-C (including C) can be useful. The Foundation and Cocoa APIs are still written in C and Objective-C. In order to interact with them, you might have to know what those languages would expect.
The Scope of This Book
Programming iOS 13 is the second of a pair with my other book, iOS 13 Programming Fundamentals with Swift; it picks up where the other book leaves off.If writing an iOS program is like building a house of bricks, iOS 13 Programming Fundamentals with Swift teaches you what a brick is and how to handle it, while Programming iOS 13 hands you some actual bricks and tells you how to assemble them.
So this book, like Homers Iliad, begins in the middle of the story. The reader is expected to jump with all four feet into views and view controllers.Topics such as the Swift programming language, the Xcode IDE, including the nature of nibs, outlets, and actions, and the mechanics of nib loading, and the fundamental conventions, classes, and architectures of the Cocoa Touch framework, including delegation, the responder chain, keyvalue coding, keyvalue observing, memory management, and so on,were all taught in iOS 13 Programming Fundamentals with Swift.
So if something appears to be missing from this book, thats why! If you start reading Programming iOS 13 and wonder about such unexplained matters as Swift language basics, the UIApplicationMain
function, the nib-loading mechanism, Cocoa patterns of delegation and notification, and retain cycles, wonder no longer! I dont explain them here because I have already explained them in iOS 13 Programming Fundamentals with Swift. If youre not sufficiently conversant with those topics, you might want to read that book first; you will then be completely ready for this one.
Heres a summary of the major sections of Programming iOS 13:
describes views, the fundamental units of an iOS apps interface. Views are what the user can see and touch in an iOS app. To make something appear before the users eyes, you need a view. To let the user interact with your app, you need a view. This part of the book explains how views are created, arranged, drawn, layered, animated, and touched.
starts by discussing view controllers. Perhaps the most important aspect of Cocoa programming, view controllers enable views to come and go coherently within the interface, allowing a single-windowed app running on what may be a tiny screen to contain multiple screens of material. View controllers are used to manage interface and to respond to user actions; most of your apps code will be in a view controller. This part of the book talks about how view controllers work, and the major built-in types of view controller that Cocoa gives you. It also describes every kind of view provided by the UIKit framework the primary building blocks with which youll construct an apps interface.
surveys the most commonly used frameworks provided by iOS. These are clumps of code, sometimes with built-in interface, that are not part of your app by default, but are there for the asking if you need them, allowing you to work with such things as sound, video, user libraries, maps, and the devices sensors.
wraps up the book with some miscellaneous but significant topics: files, networking, threading, and how to implement undo.
summarizes the basic lifetime event messages sent to your app.
catalogs some useful utility functions that Ive written. My example code takes advantage of these functions, so you should keep an eye on this appendix, consulting it whenever a mysterious method name appears.
is an excursus discussing an often misunderstood aspect of iOS programming: asynchronous code.
Someone who has read this book and is conversant with the material in iOS 13 Programming Fundamentals with Swift should be capable of writing a real-life iOS app with a clear understanding of the underlying fundamentals and techniques and a good sense of where the app is going as it grows and develops. The book itself doesnt show how to write any particularly interesting iOS apps, but it is backed by dozens of example projects that you can download from my GitHub site, http://github.com/mattneub/Programming-iOS-Book-Examples, and it uses my own real apps and real programming situations to illustrate and motivate its explanations.