Swift & SwiftUI
Swift and SwiftUI explained with working code examples: concurrency, data flow, layout and common compiler errors.
-

Fix: UITextView Does Not Grow to Fit Its Text in UIKit
Learn how to make a UIKit UITextView grow with its text using sizeThatFits and a height constraint, including setup, editing updates, and…
-

Fix: `addObserver` Not Receiving Notifications in Swift
Learn how to add a NotificationCenter observer in Swift, fix selector and notification-name mistakes, and remove observers safely when they are no…
-

How to Log in Swift: print, NSLog, and Logger
Compare Swift print, NSLog, and Logger, learn what happened to println, and choose the right option for debugging or viewing device logs.
-

Fix: `UIDevice.model` Shows Only Device Type in Swift
Use Swift’s Darwin `uname` call to read a device identifier, map it to a friendly model name, and handle unknown devices and…
-

How to Make an Attributed String in Swift (Styled Unit Suffix)
Build an NSAttributedString in Swift, append a differently styled unit like “g” to a changing number, and show it in a UILabel…
-

Fix: Cannot Append to an NSDictionary in Swift (Use Dictionary)
NSDictionary has no append method and is immutable. Switch to a Swift Dictionary, add keys with subscript syntax, and bridge back when…
-

How to Generate a Random Number in Swift (Modern API)
Use Int.random(in:), Double.random(in:) and randomElement() in Swift, seed a generator for repeatable results, and drop arc4random without modulo bias.
-

Fix: Cannot Subscript String with an Int in Swift
Learn why Swift strings don’t support integer subscripting and get ready-to-use extensions for safe character access by index.
-

How to Change the Background Color of a SwiftUI View
Set a SwiftUI view background color that actually fills the screen, handle safe areas, and style TabView and navigation bars without white…
