Even though I have been a software engineer for a very long time, never having owned an iPhone, I never got interested in learning iOS development. I plan to change that over the next few days.
The goal is to create an iOS app for what I prototyped here using the Ionic framework. Ionic is an excellent way to get started with creating hybrid apps using AngularJS. It also includes Cordova (formerly PhoneGap) provides the glue to turn the app native for iOS and Androd.
In this first session, I got familiar with Swift using a few online tutorials from Pluralsight. All my Swift learning is here on GitHub. I started with whatever version of Xcode & Swift I had, and after a few exercises realized that Swift 2.0 has been out since a few months ago.
Next, let’s get a little more ‘appy.
I. Creating the UI
A ‘Scene’ are what you see on the “screen” — a collection of all the UI elements you see on the screen. I believe my target app will have at least 4 scenes:
- The ‘Home’ screen with the list of ideas sorted in some order.
- The ‘Details’ screen for an idea.
- The ‘Capture a new idea” screen
- The ‘About this App’ screen.
Created a new Xcode project: A ‘Single View Application’.
“Storyboard” the views: It’s exactly what it sounds like — You create View Controllers and add the View elements (e.g. Table View) to the controllers which are individual screens.
I sized every view to iPhone 4.7-inch — apparently that’s what is iPhone 6.
Creating Segues: The transitions where you move from one scene to another scene.
I needed to do a couple of things to make our first scene “active”. After selecting the Table View and using the “Interface Builder”, I added a dataSource and a delegate to the View Controller. It’s some drag and drop magic.
Next, linking some static data to show up in this TableView
Now we are getting into some real code. The ViewController needs to implement a couple of TableView methods that does the following
- Returns how many elements are in the table
- Returns the cell that needs to be displayed
Note: The ViewController by default inherits from UIViewController. The first thing I did was to change this into a UITableViewController.
And Voilà! we have display.
The controller code above should have produced a working app. But I kept getting this runtime error when running the simulator. After some futzing around looking for what I can delete, I have liftoff.
There we have it. I will call this an end to Session I. I am not sure how many more sessions to go before I get to a working app that could even be a candidate to make it into the AppStore, but if you would like to follow long, I will have the code on GitHub.