String
-
How to Write Multiline Strings in Swift
Learn to create multiline strings in Swift with triple-quoted literals, concatenation, and joined arrays. Fix unterminated string errors and indentation.
-
How to Extract Regex Matches in Swift Without NSRange Errors
Learn how to extract regex matches from a String in Swift using native Regex, NSRegularExpression, and safe Range conversions for Unicode text.
-

How to Capitalize Only the First Letter in Swift
Capitalize only the first letter of a Swift String without altering the rest. Includes StringProtocol extensions, mutating methods, and Unicode-safe examples.
-

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 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 Get a Substring by Range Using String.Index
substringWithRange is gone from Swift. Learn how to slice a String with String.Index ranges, prefix/suffix, NSRange conversion, and a safe Int-offset helper.
-

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.
-

Swift String Replacement: Replace Characters the Right Way
Replace characters in a Swift String with replacingOccurrences, the iOS 16 replacing(_:with:) API, or a single-pass map. Includes first-match and regex examples.
-

How to Get the Length of a String in Swift (Use count)
Swift strings have no length property. Use count for visible characters, and utf16.count when you need UTF-16 offsets for NSRange or UIKit…
-

Swift Substring: Fix ‘String’ has no member ‘substringWithRange’
Fix the Swift error ‘Value of type String has no member substringWithRange’ and learn the modern prefix, suffix, index and range ways…