Learning Swift

This blog is for me to keep track of and maybe help other people to learn the iOS programming language Swift.

I am working my way through the iTunes U course "CS193P: Developing iOS 8 Apps with Swift" from Stanford University and using The Swift Programming Language (Swift 2.2 Edition) from Apple.

Class 1

Platform Components 

  • Tools: XCode
  • Languages: Swift (and Obj-C)
  • Frameworks: Foundation, Core Data, UIKit: main framework , Core Motion, Map Kit
  • Design Strategy: MVC - Master View Controller

Demo

  • Build a Calculator 
    • Single View Application
      • Product Name: Calculator 
      • Org Name: FisherMichaels 
      • Org ID: com.FisherMichaels
      • Bundle ID: com.FisherMichaels.Calculator
      • Language: Swift
      • Device: Universal
    • Storyboard 
      • Drag in Label to top left guidelines, resize to right guideline, Type "0", Right justify, 32 pt font, resize box to fit
      • Ctrl-drag from label to View, Trailing Space to container margin, Ctrl-drag from label to View, Leading Space to container margin, Ctrl-drag from label to View, Top Space to container margin
      • In Doc Outline, look for problem areas
        • Update Constraints: Make it look like my arbitrary decisions said it was, rarely use this
        • Reset to Suggested Constraints: Removes already set constraints 
        • Update Frames: Change the Label to how it should be
      • Open Assistant Editor,  clear out class ViewController{
        • //Ctrl-drag from label to in class, Outlet, Name: display
        • @IBOutlet weak var display: UILabel!
        • }
      • Drag in Button to mid-left, name "7", resize and embiggen font
        • //Ctrl-drag from button to in class, Action, Name: appendDigit, Type: UIButton, Touch Up Inside, Argument: Sender 
        • @IBAction func appendDigit(sender: UIButton){
          • var inMiddleOfTyping: Bool = false
          • let digit = sender!.currentTitle
          • if inMiddleOfTyping {
            • display.text = display.text! + digit
          • } else {
            • display.text = digit
            • inMiddleOfTyping = true
          • }
          • }
      • Copy/Paste and guideline up to build numberpad, move whole pad and line up to below label, left