Pitch Perfect: Part 1

Udacity asks we put forth a minimum of 10 hours per week when enrolled in a Nanodegree program. After just a day, I’ve already set myself up for a successful first week. The initial project we’re learning to develop is called Pitch Perfect. This app will, in the end, allow the user to record their voice, and apply one of four audio effects to it, such as  s l o w i n g  i t  d o w n.

Starting out, Kunal Chawla, the wonderful instructor in the provided video lessons, walks us through opening Xcode for the first time. We learn how to create a new Swift-based project, and get a basic understanding of the interface and the debug simulator we’ll be using, as well as learn how the MVC (Model-View-Controller) relates to iOS apps. The View in this case is what the user sees, so from there, we dive right into adding our very first image-based button to the View, which includes a lesson on how to add image resources for non-retina devices, 2x-resolution image resources for retina devices, and 3x-resolution image resources for the iPhone 6 Plus.

To my surprise, Apple has made it extremely easy to get started. After adding a static image as a button and running the app in the simulator, you get a sense that the image is in fact a button. Clicking it gives a visual indication of it being pressed, and you’re able to change the enabled state of it which can again be visually recognized, all without needing to provide separate images for each state.

Moving on with Kunal’s lessons, he shows us how easy it is to bind a View element, such as our image button (which is of a microphone), to our ViewController (a Swift code file that inherits from UIViewController). When you want an action to occur as the result of a button being pressed, you would create an IBAction (which is an Interface Builder Action). To then have that button show visual feedback, and change the state of something on the View, such as having a label appear, you would bind the label to the ViewController with an IBOutlet. We learn that the difference between an Action and an Outlet is that an Action is a way for the View to tell the Controller that something happened, while the Outlet is a way for the Controller to manipulate (or control) the View. Defining these bindings is incredibly simple: hold the control key, and drag a line from the element over to the Swift code, within the class enclosure, and let go; Xcode will then prompt you for a name, whether it’s an Outlet or an Action, and a couple of other settings.

After a relatively short amount of time, we have a working example of a microphone button that, when pressed, disables itself while a “recording” label and a stop button appear like swift magic. Of course, you can yell into your device’s microphone all you want, at this point it’s not actually recording anything. In fact, we haven’t even gotten to that step in the project just yet!

Pitch Perfect: Part 1

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 )

Google+ photo

You are commenting using your Google+ 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