This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Collection { | |
/// Safe subscription for collection elements. | |
/// | |
/// - Parameter safe: The index of which the element should be returned. | |
/// - Returns: The element at the given index if present, otherwise nil. | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let defaults = UserDefaults(suiteName: "GistApplication") | |
/// A Property wrapper around UserDefaults which makes it easier to interact with. | |
@propertyWrapper struct UserDefault<T> { | |
/// The key of the entry which should be added to the defaults. | |
let key: String |
OlderNewer