Swift and Udacity

I have been writing iOS code since 2012. I have taken some online courses along the way as well. During this journey I have released three (3) apps on the AppStore. This year I am head first into making a transition to becoming a full-time iOS developer. Currently my daytime job is in the construction industry, namely doing carpentry/framing of interior spaces in New York City. I am very excited to do this career transition. However there are voids in my coding that I feel need improving upon, hence Udacity iOS Nanodegree. I came across Udacity last weekend while searching for tutorials on iOS integration with Web Services. Udacity provides a structured course with career development guidance.

What have I learned so far in the Udacity Nanodegree course?
The current lecturer, namely ,Kunal Chawla, started lesson 1 with walking us through the Xcode development environment. We learnt about the Xcode UI. The three main windows being: the Navigator on the left, Editor in the center and the Utilities Area on the right. The navigator as the name implies allows you to navigate through the files and assets of your project. The Editor is where code is written for your app and the Storyboard/UI is also manipulated and configured in the Editor area. The Utilities area has the object library, widgets to add to the UI such as buttons, labels, image view etc. In lesson 2 we started working on an app called Pitch Perfect. The app enables a user to record audio and modify that audio recording with various effects. In that lesson we started building the app. We added a microphone button and stop button to the initial view. We also custom added an image asset to the microphone and stop button. In iOS there are three asset sizes that a developer needs to provide. There is the 1x asset for iOS devices prior to Retina and there is 2x that’s Retina optimized and the newest 3x asset for iPhone 6 and 6 Plus. Autolayout was used by adding constraints to views to keep them aligned in various screen sizes relative to a reference point. In lesson 3 and 4 more implementation was added to the app to create its feature set. We embedded the initial scene in a Navigation Controller to allow transitioning between screens. With the navigation controller the Pitch Perfect app is now able to transition from the first screen with the microphone to the second screen which has the effects the user can choose from to manipulate their recorded audio.

AVFoundation framework enables all the audio development in Pitch Perfect. As with any Framework the library needs to be imported into your class so you can make full use of its methods and properties.

In iOS there is a fundamental programming concept known as MVC. Model, View, Controller. This practice is highly recommended in developing apps as it keeps those three principles separate and concise thus making the apps implementation easier for the developer and anyone reading their code to understand.

The Model is all the data objects of the app. In an app like Flickr that would be the photos, users, geolocation, etc. In Pitch Perfect its the recorded audio, title, file path.

The View is the user interface of the app. All the UI the user interacts with makes up the View. Buttons, Keyboard, Text Fields, Date Picker and so on. UIKit, a Cocoa class makes most of those UI View elements available to your app. Examples are UITableView, UIButton, UIViewController, UIDatePicker…… More can be seen under the documentation for UIKit.

The controller is the glue that keeps it all together. The communicator between the Model and View is handled by the Controller class. In the case of Pitch Perfect it’s the file RecordSoundsViewController.swift This file responds to actions that the user makes. Example, tapping on the microphone to record their voice. Switching between views, that’s all the job of the Controller. UIViewController is one of the most powerful UIKit classes. The view cycle of an application lies within the functions of UIViewController. Setting up the initial state of an app when it first launches for example can be customized in the viewDidLoad method of UIViewController. This class is also the parent class of UINavigationController which in itself is a powerful class.

To test our application development builds we used the iOS simulator. It’s able to simulate all iOS devices including the iPad.

To become a great developer you have to get use to reading and exploring the Apple Developer Documentation is paramount. In the docs there is code for Objective-C and now Swift. Most of the API is still written in Objective-C. So knowing Objective-C is still essential to landing an iOS developer job.

Delegation is one of the widely used practices in everyday iOS development. That’s where a calling object delegates task to the delegate and is able to be notified of changes in that Framework. That particular Cocoa Framework would have a set of protocols, some of which are optional and some may be required. If the protocol method is required it must be implemented in order for it to conform to the Class’s Delegate. A typical example is what cell did a user tap on? In the UITableView Class this delegation is done by the method didSelectCellAtIndexPath method. More on delegation in the documentation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s