array[0] isn't magic. Your own types can have subscripts too.
6 patterns + 1 gotcha in one image. Full carousel on LinkedIn ๐
https://t.co/d9iqo6a114
#Swift#iOSDev
1/2
Five Swift solutions to LeetCode 125, all O(n), up to 1.5x apart in speed. UTF-8 bytes won at 284 ms for 1,000 runs, and elementsEqual(reversed()) came last.
Code :
Run it in your browser :
#Swift#iOSDevelopment#LeetCode
Iโm proud to share ๐๐ฒ ๐ ๐ฒ๐ฟ๐ฒ ๐ฃ๐๐ฎ๐ฎ๐ฟ๐ฒ ๐ช๐ฎ๐๐ฎ๐ป, a song created by my brother and his team. It means a lot to me to share something theyโve made together.
1/2 Property wrappers are a getter and setter in a box: write the logic once, reuse it with one @. Hereโs how they work, where they shine, and the threading trap that catches people out.
#Swift#iOSDevelopment#SwiftUI
1/2
static and class both put a property on the type, but only class lets a subclass override it. Default to static, use class on purpose, and in Swift 6 watch out for mutable statics.
#Swift#iOSDevelopment#SwiftLang
Claude Code has a command for โletโs pick this up tomorrow.โ Itโs /resume.
Two others worth remembering mid-debug: /context shows whatโs filling the context window, and /compact summarizes a long session so you can keep going.
All 18 commands in one cheat sheet โ
#ClaudeCode
1/3
When does Swift require self in a closure? In a class, self. can fix an escaping-closure error. In a mutating struct method, even self. wonโt help. I put the 4 rules side by side, with a cheat sheet on the last slide. #Swift#iOSDev
1/3
I usually write scores.sorted { $0 > $1 }. Reading Swiftโs Closures chapter reminded me I can pass the operator itself: scores.sorted(by: >).
I put 8 ways to write the same sorting call side by side in this PDF. Which one do you use?
#Swift#iOSDevelopment#SwiftLang
1/2
Where Array, Set and Dictionary diverge in Swift, past the basics.
Set and Dictionary order can change between launches, so sort before you display.
#swift#iosdev#swiftlang#iosdevelopment#mobiledev
๐ค๐ญ
Ans: B. It prints cafรฉ, then 4 4. .count counts characters, and \u{301} merges into the e, so โcafeโ becomes โcafรฉโ and stays at 4.
๐ค๐ฎ
Ans: B. It prints 2, then 1. On its own, each string is one character. Joined, the accent attaches to the e and they become a single รฉ.
Quick Swift quiz. I appended something to a string, did the count change?
Take a guess before looking into the comments section. I will share the answer shorlty
#Swift#iOSDevelopment
1/2
In Swift strings, """ controls lines and # controls escapes, and you can combine them. Hereโs a 7-slide guide with outputs for every example, plus the hex-colour gotcha that ends a string early.
#Swift#iOSDevelopment#SwiftLang