CocoaCheerleaders

Hints, tips and code snippets for Swift and SwiftUI. Short, focused, and ready to paste into Xcode.

Latest tips

Automatic plurals with inflect: true

Text("^[\(count) item](inflect: true)") picks "1 item" or "2 items" for you, with no if statements and no plural rules of your own.

18 November 2026 · Text and localization

Format dates the reader's way with Date.FormatStyle

Ask for the date fields you want and let the locale decide the order, separators and 12 or 24-hour clock. No more dateFormat strings.

18 November 2026 · Formatting

Stop using String(format:) for money

Text(price, format: .currency(code:)) formats money for the reader's locale: symbol, separators and decimals included.

18 November 2026 · Formatting

"5 minutes ago" and live countdowns in SwiftUI

Text can show relative dates and run timers by itself. No Timer, no publishers, no string building.

18 November 2026 · Formatting

All tips

By category

Formatting

Numbers, currency, percentages, dates, relative time, durations, measurements and lists, formatted the right way.

3 tips

Text and localization

AttributedString, Markdown in Text, automatic grammar agreement and string catalogs.

1 tip