@@ -39,14 +39,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
39
39
launchAtLoginCheckbox. state = LoginServiceKit . isExistLoginItems ( ) ? . on : . off
40
40
41
41
switch UserDefaults . standard. string ( forKey: " timeFormat " ) {
42
- case " h:mm " :
43
- timeFormat12h. state = . on
44
- timeFormat24h. state = . off
45
42
case " HH:mm " :
46
43
timeFormat12h. state = . off
47
44
timeFormat24h. state = . on
48
45
default :
49
- return
46
+ timeFormat12h. state = . on
47
+ timeFormat24h. state = . off
50
48
}
51
49
52
50
clockBar ( )
@@ -65,7 +63,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
65
63
DFRSystemModalShowsCloseBoxWhenFrontMost ( true )
66
64
67
65
timeFormatter = DateFormatter ( )
68
- timeFormatter? . dateFormat = UserDefaults . standard. string ( forKey: " timeFormat " )
66
+ timeFormatter? . dateFormat = UserDefaults . standard. string ( forKey: " timeFormat " ) ?? " h:mm "
69
67
let nowTime = timeFormatter? . string ( from: Date ( ) )
70
68
71
69
let clockBarIdentifier = NSTouchBarItem . Identifier ( rawValue: " ClockBar " )
@@ -78,7 +76,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
78
76
79
77
// update time
80
78
@objc func updateTime( ) {
81
- timeFormatter? . dateFormat = UserDefaults . standard. string ( forKey: " timeFormat " )
79
+ timeFormatter? . dateFormat = UserDefaults . standard. string ( forKey: " timeFormat " ) ?? " h:mm "
82
80
touchBarButton? . title = ( timeFormatter? . string ( from: Date ( ) ) ) !
83
81
}
84
82
@@ -99,8 +97,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
99
97
}
100
98
}
101
99
102
-
103
-
104
100
// click status bar menu item
105
101
@IBAction func didClickStatusBarMenuItem( _ sender: NSMenuItem ) {
106
102
switch sender. tag {
0 commit comments