iOS Programming with Swift

Made With: Swift 2.0, Xcode
Time in Development: 3 Weeks

Tip Calculator

I started my journey into iOS programming with Ray Wenderlich’s helpful “Quick Start” Swift 2 tutorial. Through the process of building a simple tip calculator, I learned the basic ways in which data types, classes, and methods are handled in Swift.

I also gained a solid introduction to the general Xcode interface – how to set up a responsive user view with pins and constraints, program in the view controller, and link the view controller to the app model.

The tip calculator tutorial introduced two types of user inputs included in the UIKit: the text field and the slider.

Basic Calculator

From there, I moved on to Lynda’s Programming for Non-Programmers: iOS 9 and Swift course to build a mock-up of the basic iOS calculator – still quite simple, but with more user inputs and modes than the tip calculator.

Additions to Basic Calculator

The next step of the process was to build additional functionality into the basic calculator made with the Lynda course. This marginally more advanced calculator adds commas to longer number strings using the NSNumberFormatter class. It also includes buttons to change the sign of a number and convert a percent into a decimal.

Custom Calculator: Gravity and Weight

To test my knowledge of Swift up to this point, I tried my hand at building a custom calculator from the ground up. Based on what I had learned from the earlier iterations, I developed a simple app to calculate weight as a measure of gravity on different planets. The ratios used for this calculation were taken from The Exploratorium’s “Weight on Other Worlds” site.

For this app, I experimented with coding a new form of user input – the picker, which allows users to scroll through and select from an array. In this case, users select the planet for which they want to calculate weight as a measure of gravity.

Moving forward, one obvious functionality to add to this gravity calculator would an option to input weight in pounds or kilograms.

These simple one-page calculator apps hardly scratch the surface of what is possible in iOS programming, though, so I am eager to see what I can build as I continue to learn Swift.