Calculator App for iOS

I just completed the Lynda.com course, Programming for Non-programmers and I learned how to create a calculator app. I made a bunch of mistakes throughout the course, but I found it incredibly rewarding. I especially love that I now have a calculator built by moi!

I realized that following along with the instructor was difficult for me because I cannot type and listen at the same time. Trying to focus on typing code while also listening the explanation for using that code turned into a jumbled mess text-wise. I would run the simulator, thinking I had completed every step, only to find out that there were bits missing from the code. An =Int, or closing the {}, or even misspelling a word turned my computer screen into a huge mess of code and intimidating error messages.

It was nice to be able to rewind, pause or even watch a whole video over again to understand what I was doing. I also started using the //comment feature towards the end of the course to take notes within the code. That way, I would be able to look back in the project and understand what I was doing.

Here is an example of the notes I took in the code:

func updateText() {

guard let labelInt:Int = Int(labelString) else {

return

}

if (currentMode == .not_set){

savedNum = labelInt //not yet showing the total just setting up what happens when you press the addition or subtraction buttons

}

//add a number formatter to change the text a bit to add a comma or dot.

let formatter:NumberFormatter = NumberFormatter()

formatter.numberStyle = .decimal

let num:NSNumber = NSNumber(value: labelInt)

label.text = formatter.string(from: num)

// replace “\(labelInt)” with the formatter

}

func changeModes(newMode:modes) {

//make sure there is already information in the calculator. Then it will keep the last number on the screen until the user presses another numeric button.

if (savedNum == 0) {

return

}

currentMode = newMode

lastButtonWasMode = true

}

}

If you want to watch a brief demonstration of the app, you can check it out on Youtube.