@amarjit_uk Apple doesn't ship one kitchen-sink app. Closest official: SwiftUI tutorials + the HIG. For live samples, search GitHub for "SwiftUI Kitchen Sink" and pick a recently updated repo; SwiftUI Lab write-ups help too. Sheets/dialogs shift each OS, so check the current HIG.
Swift tip: reduce folds an array down to one value.
let scores = [10, 20, 30]
let total = scores.reduce(0, +)
// 50
The 0 is the starting total; + adds each score into it.
Practice it in your browser: https://t.co/QD4QaAiWDD
@osvaldomercadoe@twostraws Welcome aboard! A tip for the early days: type the examples out yourself in a playground instead of just watching. Changing a value and seeing what breaks teaches a lot. Have fun with Day 1!
@SelenYel@twostraws Day 9 is where closures click. A handy one: when a closure is the last argument you can write it after the parentheses, like names.sorted { $0 < $1 }. Same thing, just less typing. Keep going!
Swift tip: filter keeps only the elements that pass your test.
let scores = [42, 88, 67, 95]
let passed = scores.filter { $0 >= 60 }
// [88, 67, 95]
Order stays the same, and scores itself doesn't change.
Practice it in your browser: https://t.co/QD4QaAioO5
@iPradDev Learning SwiftUI, a habit that helped me: after each small app, rebuild one screen from scratch without looking. Also get comfortable with @State vs @Binding early, most beginner bugs come from there.
@Revolt3r Good way to keep it honest: pick one generated view each day and explain what @State, @Binding and the modifier order are doing. If you can change it without asking the agent, you actually understand it.
Swift tip: ?? gives an optional a default value.
let name = username ?? "Guest"
If username is nil, name is "Guest". Otherwise you get the unwrapped value.
Try it in your browser: https://t.co/QD4QaAiWDD
Swift tip: compactMap is map that drops the nils.
let inputs = ["4", "abc", "9"]
let numbers = inputs.compactMap { Int($0) }
// [4, 9]
"abc" can't become an Int, so it's skipped.
Practice it in your browser: https://t.co/QD4QaAiWDD
@JayRedDev For the spin, rotation3DEffect with an amount that changes when a button is tapped works well. Pair it with withAnimation so the 360 degrees actually animates.
@denysdzhyma@twostraws Day 16 already, nice. Try rebuilding one small view from memory without the video, that's when the SwiftUI patterns really start to stick.
Swift tip: map turns every element into something new and gives you a fresh array.
let prices = [3, 5, 8]
let labels = https://t.co/DrFwkLMJyH { "$\($0)" }
// ["$3", "$5", "$8"]
The original array stays untouched.
Practice it in your browser: https://t.co/QD4QaAiWDD
@iniyanai Good question. Even if AI writes a lot of it, you still need to read and debug what it gives you, so knowing the basics seems worth it to me.
@HarshithAshvi@priymrj Congrats on the first sale! Going from a Mac you hadn't touched to a paid app in three months is a great story, and building simple apps by hand first clearly paid off.
Swift tip: defer runs when the scope exits, however it exits.
func load() {
print("start")
defer { print("cleanup") }
print("work")
}
// start, work, cleanup
Handy for closing files or resetting state.
Try it in your browser: https://t.co/QD4QaAiWDD
@PadraigOraghail@NathanMerzke Building apps while learning is a solid way in. Writing small throwaway functions to test one concept at a time helps a lot too.
@Rajneeshvermaa Building is the best way to learn it. When something breaks, try to explain why before you search the fix. It sticks way better that way.