Join Bill Weinman for an in-depth discussion in this video About Swift, part of iOS SDK and SQLite: Building Data-Driven Apps.
- Swift is a new programming language that was introduced by Apple at the Worldwide Developers Conference in June 2014. Swift is specifically designed for Cocoa and Cocoa Touch, Apple's API for OS10 and iOS. Swift is intended to be more concise and less prone to error than Objective-C. While Apple is not implied that Swift is intended to entirely replace Objective-C, it's clear that it is intended to be used for application programming tasks where Objective-C may have been used in the past.
I chose to use Swift for this project because this is the direction that application development is heading for Apple's platforms. During the course of preparing this course, and converting this code from Objective-C to Swift, it became clear to me that Swift is still very much a work in progress. After I had completed converting all of the code, Apple announced Swift version 1.2 with major changes to the language. The code I had just finished would no longer compile and run with the new version of Swift, and Apple did not provide backward compatibility to support the previous version of the language.
That required that I update all of my code and conduct extensive testing, then update all of the example files and rewrite a lot of this course. The experience taught me that Swift is not necessarily stable in its current form. In other words, code that you write today will likely need to be refactored in the future. And that's not necessarily a bad thing considering that iOS changes every year anyway. But it is something you should consider before committing a lot of resources to using Swift in your projects.
So why did I choose to do this project in Swift? Swift is clearly where Apple is going with application development. And if we intend to develop for Apple platforms in the long term, it's going to be essential that we know Swift and we know it well. With that in mind, I've spent a lot of time making sure that the Swift code in this course is clear, concise and correct. I'm sure it's not perfect. I'm sure I can continue to improve it. But it's been my intent to make it a good example of quality Swift code.
I also chose to keep the database classes in Objective-C. I did this for a couple of reasons. First, it's fairly low-level code. That is, it interfaces directly with the SQLite, C language library. It would certainly be possible to do this in Swift, but it wouldn't be ideal. This is the sort of thing I expect will continue to be written in Objective-C for the long term. I also wanted to show you how to mix the two languages in one application. This is an important skill. And if you're doing any serious work in iOS, I expect this scenario to come up for you, and I wanted to give you a good example of how to mix these two languages effectively.
Swift is an important development, both for iOS and for programming in general. It's a thoroughly modern language. It takes features from innovative languages like Haskell, Ruby and Python, while retaining a great deal of the performance advantages of compiled languages like Objective-C. I will be paying close attention to the evolution of Swift in the coming years, and I hope you will, too.
- Building a testbed
- Creating an Objective-C interface for SQLite
- Creating a CRUD interface
- Designing the database schema
- Creating the main table view
- Creating the items table view
- Adding new feeds
- Parsing feeds with NSXML Parser
- Viewing webpages
- Preparing icons and toolbar images
- Adding a preferences pane
- Including pull-to-refresh and other features