final class Settings { let userDefaults = UserDefaults.standard public static let shared = Settings() let defaults: [String : Int] = ["minute" : 4, "second" : 59] private init() { self.minute = userDefaults.integer(forKey: "minute") self.second = userDefaults.integer(forKey: "second") } private var _interval: Int = 0 var interval: Int { get { return _interval } set { _interval = newValue } } private var _minute: Int = 0 var minute: Int { get { return _minute } set { _minute = newValue } } } ------------------------- // 設定を初期化する let _ = Settings.shared minStepper.value = Double(Settings.shared.minute)