Swift
-

Fix: String-to-Double Conversion Fails in Swift
Learn how to convert a Swift String to Double safely, reject invalid input, and parse decimal or currency text using the right…
-

Fix: UITextField Text Change Event Reads Old Text in Swift
Use UIKit’s .editingChanged event to read the updated UITextField value, recalculate dependent fields, and avoid stale text in shouldChangeCharactersInRange.
-

Fix: `UITapGestureRecognizer` Won’t Fire Programmatically
Stop calling nonexistent UIView event APIs: attach a UITapGestureRecognizer correctly, invoke shared tap logic in unit tests, or tap the view in…
-

Fix: Convert an ISO 8601 String to `Date` in Swift
Parse an ISO 8601 timestamp like `2016-04-14T10:44:00+0000` into Swift `Date`, handle its UTC offset, and safely extract the year, month, day, 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.