1 of 22

Intro to iOS App Dev

Ananay Arora

@ananayarora

App Development using Swift and SwiftUI

2 of 22

What we’ll be making today

3 of 22

Prerequisites

Xcode

(Install from Mac App Store)

4 of 22

A little bit of context…

Swift

SwiftUI

5 of 22

A little bit of context…

6 of 22

Quick intro to Swift

7 of 22

// Prints Hello World to the console

print("Hello, world!")

// Declares a variable

var myVariable = 42

// Declares a constant

let myConstant = 420

// Declares a variable with type String

var myName: String = "Ananay"

8 of 22

let apples = 3

let oranges = 5

// String interpolation

let appleSummary = "I have \(apples) apples."

let fruitSummary = "I have \(apples + oranges) pieces of fruit."

9 of 22

// Array of Strings

var shoppingList: [String] = ["Eggs", "Bread", "Milk"]

// Add cheese to the list

shoppingList.append("Cheese")

// Print the first element

print(shoppingList[0]) // Eggs

// Loop over the shopping list

for item in shoppingList {

print(item)

}

10 of 22

// Struct

struct Person {

let id = UUID()

let name: String

let age: Int

}

let person1: Person = Person(name: "John Doe", age: "42")

let person2: Person = Person(name: "Jane Doe", age: "40")

11 of 22

Intro to SwiftUI

12 of 22

var body: some View {

List {

}

}

13 of 22

var body: some View {

List {

Text("A List Item")

Text("A Second List Item")

Text("A Third List Item")

}

}

14 of 22

var body: some View {

var shoppingList = [

"A List Item",

"A Second List Item",

"A Third List Item"

]

List {

ForEach(shoppingList, id: \.self) { item in

Text(item)

}

}

}

15 of 22

var body: some View {

var teamsList = ["A", "B", "C"]

NavigationView {

List {

ForEach(teamsList, id: \.self) { team in

NavigationLink(destination: {}) {

Text(team)

}

}

}

}

}

16 of 22

var body: some View {

var teamsList = ["A", "B", "C"]

NavigationView {

List {

ForEach(teamsList, id: \.self) { team in

NavigationLink(destination: {}) {

Text(team)

}

}

}

}

}

17 of 22

18 of 22

Let’s get to building it.

19 of 22

@State private var counter: Int = 0

var body: some View {

Button(String(counter)) {

counter = counter + 1

}

}

20 of 22

CURIOSITY AND CONSISTENCY ARE 🔑!

21 of 22

Thank you!

22 of 22

One more thing…