This file contains hidden or 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
public class Preferences: ObservableObject { // It actually doesn't matter that it's an ObservableObject but there's no reason for it not to be | |
@UserDefault("workout-length") public var workoutLength = Defaults.workoutLength | |
@UserDefault("rest-length") public var restLength = Defaults.restLengh | |
@UserDefault("workout-phase-set-identifiers") public var workoutPhaseSetIds = [String]() | |
#if !os(watchOS) | |
@UserDefault("playlist-id") public var playlistID: String? | |
@CodableUserDefault("workout-communicator") public var workoutCommunicator: WorkoutCommunicators? // This is an example of a codable enum getting saved into UserDefaults | |
#endif | |
This file contains hidden or 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
// BAD | |
let idgaf: UILabel = { | |
let label = UILabel() | |
label.text = "huh" | |
return label | |
}() | |
// GOOD | |
let disIsGood = configure(UILabel() { | |
$0.text = "YAAY" |
This file contains hidden or 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
struct Model { | |
var id: String | |
var value: Int | |
} | |
var arrAsDict = [ | |
Model(id: "foo", value: 2), | |
Model(id: "bar", value: 5) | |
] |
This file contains hidden or 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
// | |
// SegTab.swift | |
// SegmentedControlAsTabs | |
// | |
// Created by Patrik Svoboda on 20/07/2019. | |
// Copyright © 2019 Patrik Svoboda. All rights reserved. | |
// | |
import SwiftUI |