Open annareedsmalley opened 9 years ago
@codepathreview, see animated gif above.
Here's my code - not sure what else to do with it but paste it here:
// // ViewController.swift // tips // // Created by Anna Smalley on 9/27/15. // Copyright © 2015 Anna Smalley. All rights reserved. //
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var tipControl: UISegmentedControl!
@IBOutlet weak var billField: UITextField!
@IBOutlet weak var totalLabel: UILabel!
@IBOutlet weak var tipLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
tipLabel.text = "$0.00"
totalLabel.text = "$0.00"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func OnEditingChanged(sender: AnyObject) {
var tipPercentages = [0.18, 0.2, 0.25]
var tipPercentage = tipPercentages[tipControl.selectedSegmentIndex]
var billAmount = NSString(string: billField.text!).doubleValue
var tip = billAmount * tipPercentage
var total = billAmount + tip
tipLabel.text = "$\(tip)"
totalLabel.text = "$\(total)"
tipLabel.text = String(format: "$%.2f", tip)
totalLabel.text = String(format: "$%.2f", total)
}
@IBAction func onTap(sender: AnyObject) {
view.endEditing (true)
}
}
Good work. This prework is a preview of our weekly project process. Generally, weekly projects take between 5-10 hours to complete the required features and an additional 5-10 hours to complete the optional features. In general, we've seen that the more hours you log, the quicker you improve your proficiency with iOS.
In order to prepare for the design class, you should start thinking about app ideas that you're interested in building and create paper or digital wireframes. Note that the prototyping techniques that we'll be teaching are well suited for fun/social/productivity apps like Yahoo, Facebook, Dropbox, Airbnb, etc.