Skip to content

Instantly share code, notes, and snippets.

@davidsteppenbeck
davidsteppenbeck / PreviewProviderModifier.swift
Last active October 31, 2022 10:30
A SwiftUI view modifier for simple preview providers.
import SwiftUI
enum PreviewProviderMode: CaseIterable {
/// Use for a light appearance preview.
case lightMode
/// Use for a dark appearance preview.
case darkMode
@douglashill
douglashill / LocalisedStrings.swift
Last active September 17, 2018 09:02
Generating an enum to ensure only defined localised string keys are used. For development on Apple platforms.
// Douglas Hill, February 2018
import Foundation
/// Returns a localised string with the key as an enum case so the compiler checks it exists.
/// The enum should be automatically generated using UpdateLocalisedStringKeys.swift.
public func localisedString(_ key: LocalisedStringKey) -> String {
return Bundle.main.localizedString(forKey: key.rawValue, value: nil, table: nil)
}