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

Fix: ‘keyWindow’ Was Deprecated in iOS 13.0 — Modern Window Access in Swift
Learn why keyWindow was deprecated in iOS 13 and how to safely access the key window using UIWindowScene and connectedScenes for single…
-

How to Get an Element’s Index Inside ForEach in SwiftUI
Learn how to get the element index inside SwiftUI ForEach using enumerated(), array.indices, and bindings without breaking dynamic UI updates or crashing.
-

How to Remove the Last Character of a Swift String
Learn how to remove the last character of a Swift String with dropLast(), popLast(), and removeLast() without crashing on empty inputs or…
-
How to Throw a Custom Error Message in Swift Without Boilerplate
Learn how to throw an error with a custom string message in Swift using LocalizedError structs, single-case enums, String extensions, or NSError.
-

How to Add an Activity Indicator in SwiftUI
Learn how to add a spinning activity indicator and full-screen loading overlay in SwiftUI using ProgressView or a UIActivityIndicatorView wrapper.
-

How to Get the iOS Status Bar Height in Swift and SwiftUI
Learn how to get the iOS status bar height programmatically in Swift using UIWindowScene, safeAreaInsets, and SwiftUI GeometryReader without deprecated APIs.
-

How to Trim Whitespace From a String in Swift
Learn how to trim leading and trailing whitespace and newlines from a String in Swift using trimmingCharacters(in:), custom extensions, and pure Swift.
-

How to Convert NSURL to NSString in Objective-C and Swift
Learn how to convert NSURL to NSString in Objective-C and URL to String in Swift using absoluteString or path, and avoid common…
-
Fix: Unwanted Padding and Margins in UITextView on iOS
Remove unwanted padding and margins inside UITextView on iOS by setting textContainerInset and lineFragmentPadding to zero in Swift or Storyboard.
