Swift 5
-

How to Lock One View Controller to Portrait Mode in UIKit
Learn how to lock a single UIViewController to portrait while the rest of your UIKit app supports all orientations, using AppDelegate and…
-

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 Add an Element to a Swift Array (Append, Insert, Prepend)
Swift has no push or unshift: use append, insert(at:) and append(contentsOf:) correctly, and learn why prepending an element is never constant time.
-

Swift enumerated(): Loop With Index and Element Together
Use enumerated() to loop over a Swift array with both index and element, build arrays of pairs, and avoid the offset-vs-index trap…
-

How to Find the Index of an Item in a Swift Array
Find an item’s index in a Swift array with firstIndex(of:), lastIndex, and identity checks for classes. Fix the old find/indexOf errors and…