An intro to iOS development

Joshua Lin (@konekoya)

The Swift language itself

  • A compiled language
  • Statically typed
  • The successor of Objective-C
  • Developed by Apple and released in 2014
  • Open source and hosted on GitHub
  • Can also be used as a backend language: E.g Vapor

What does it taste like?

Closure

Simply put: lambdas in other language :)


// sorted(by:) method accepts a closure that takes two arguments of the same type as the array’s contents

let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

// 1. Write a function that of the correct type: (String, String) -> Bool.
func backward(_ s1: String, _ s2: String) -> Bool {
    return s1 > s2
}

var reversedNames = names.sorted(by: backward)
// reversedNames is equal to ["Ewa", "Daniella", "Chris", "Barry", "Alex"]

// 2. Closure Expression Syntax

// { (parameters) -> return type in
//     statements
// } 


// for the inline closure expression, the "parameters and return type are written inside the curly braces", not outside of them.
var reversedNames = names.sorted(by: {(_ s1: String, _ s2: String) -> Bool in
    return s1 > s2
})


// We write this in JS
var reversedNames = names.sort((s1: string, s2: string): boolean => {
    return s1 > s2;
});

// Inferring Type From Context
var reversedNames = names.sorted(by: { $0 > $1 } )

SwiftUI vs. UIKit

Future development of Apple platform

Support iOS 13 or later

Canvas editor

Declarative

Build App for iOS, macOS, tvOS and watchOS

Easy to use and learn

In the early development

Limit API coverage

Support iOS 2 or later

imperative

Stable, mature

Comprehensive API coverage

Only works for iOS, not other Apple platforms

IDE

  • Everyone uses Xcode here 😳
  • Run your app with canvas editor and device simulator

Package manager

  • Swift Package Manager, CocoaPods, Carthage
  • CocoaPods: written in Ruby,  can be installed with homebrew, easy to use

App demo

  • NightlyWatch
  • Assess clone

Resources

Thank you 🙂

An intro to iOS development

By konekoya

An intro to iOS development

  • 196