Intro to iOS App Dev
Ananay Arora
@ananayarora
App Development using Swift and SwiftUI
What we’ll be making today
Prerequisites
Xcode
(Install from Mac App Store)
A little bit of context…
Swift
SwiftUI
A little bit of context…
Quick intro to Swift
// 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"
let apples = 3
let oranges = 5
// String interpolation
let appleSummary = "I have \(apples) apples."
let fruitSummary = "I have \(apples + oranges) pieces of fruit."
// 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)
}
// 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")
Intro to SwiftUI
var body: some View {
List {
}
}
var body: some View {
List {
Text("A List Item")
Text("A Second List Item")
Text("A Third List Item")
}
}
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)
}
}
}
var body: some View {
var teamsList = ["A", "B", "C"]
NavigationView {
List {
ForEach(teamsList, id: \.self) { team in
NavigationLink(destination: {}) {
Text(team)
}
}
}
}
}
var body: some View {
var teamsList = ["A", "B", "C"]
NavigationView {
List {
ForEach(teamsList, id: \.self) { team in
NavigationLink(destination: {}) {
Text(team)
}
}
}
}
}
Let’s get to building it.
@State private var counter: Int = 0
var body: some View {
Button(String(counter)) {
counter = counter + 1
}
}
CURIOSITY AND CONSISTENCY ARE 🔑!
Thank you!
One more thing…