OSDN Git Service

Doutakuを導入
[kcd/KCD.git] / KCD / TimeSignalNotifier.swift
index 53d4e69..556acb4 100644 (file)
@@ -8,11 +8,6 @@
 
 import Cocoa
 
-extension Selector {
-    
-    static let fire = #selector(TimeSignalNotifier.fire(_:))
-}
-
 final class TimeSignalNotifier: NSObject {
     
     let udController: NSUserDefaultsController = NSUserDefaultsController.shared
@@ -52,14 +47,13 @@ final class TimeSignalNotifier: NSObject {
         
         let notification = NSUserNotification()
         let hour = cal.component(.hour, from: now)
-        let format = NSLocalizedString("It is soon %zd o'clock.", comment: "It is soon %zd o'clock.")
+        let format = LocalizedStrings.timerSIgnalMessage.string
         notification.title = String(format: format, hour + 1)
         notification.informativeText = notification.title
         
         if UserDefaults.standard[.playNotifyTimeSignalSound] {
             
             notification.soundName = NSUserNotificationDefaultSoundName
-            
         }
         
         NSUserNotificationCenter.default.deliver(notification)
@@ -76,18 +70,16 @@ final class TimeSignalNotifier: NSObject {
         if minutes + notifyTimeBeforeTimeSignal >= 60 {
             
             comp.hour = comp.hour.map { $0 + 1 }
-            
         }
         comp.minute = 60 - notifyTimeBeforeTimeSignal
         guard let notifyDate = cal.date(from: comp) else {
             
-            print("Can not create notify date")
-            return
+            return Logger.shared.log("Can not create notify date")
         }
         
         timer = Timer.scheduledTimer(timeInterval: notifyDate.timeIntervalSinceNow,
                                      target: self,
-                                     selector: .fire,
+                                     selector: #selector(TimeSignalNotifier.fire(_:)),
                                      userInfo: nil,
                                      repeats: false)
     }