Browse Source

10.14 compatibility.

master
Abhi 2 years ago
parent
commit
72e3849b1e
  1. 2
      Clocker/Clocker/LocationController.swift
  2. 6
      Clocker/ClockerUnitTests/AppDelegateTests.swift
  3. 2
      Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift
  4. 6
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift
  5. 2
      Clocker/Overall App/DataStore.swift
  6. 13
      Clocker/Overall App/Foundation + Additions.swift
  7. 2
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  8. 4
      Clocker/Panel/Notes Popover/NotesPopover.swift
  9. 2
      Clocker/Panel/ParentPanelController.swift
  10. 4
      Clocker/Preferences/General/PreferencesDataSource.swift

2
Clocker/Clocker/LocationController.swift

@ -80,7 +80,7 @@ class LocationController: NSObject {
var datas: [Data] = []
for updatedObject in timezoneObjects {
let dataObject = NSKeyedArchiver.archivedData(withRootObject: updatedObject)
let dataObject = NSKeyedArchiver.clocker_archive(with: updatedObject)
datas.append(dataObject)
}

6
Clocker/ClockerUnitTests/AppDelegateTests.swift

@ -20,7 +20,7 @@ class AppDelegateTests: XCTestCase {
XCTAssertEqual(dockMenu?.title, "Quick Access")
XCTAssertEqual(items.first?.title, "Toggle Panel")
XCTAssertEqual(items[1].title, "Preferences")
XCTAssertEqual(items[1].title, "Settings")
XCTAssertEqual(items[1].keyEquivalent, ",")
XCTAssertEqual(items[2].title, "Hide from Dock")
@ -102,7 +102,7 @@ class AppDelegateTests: XCTestCase {
timezone1.formattedAddress = "MenubarTimezone"
timezone1.isFavourite = 1
// Encode it in UserDefaults
let encodedTimezone = NSKeyedArchiver.archivedData(withRootObject: timezone1)
let encodedTimezone = NSKeyedArchiver.clocker_archive(with: timezone1)
DataStore.shared().setTimezones([encodedTimezone])
subject?.setupMenubarTimer()
@ -131,7 +131,7 @@ class AppDelegateTests: XCTestCase {
timezone1.formattedAddress = "MenubarTimezone"
timezone1.isFavourite = 1
// Encode it in UserDefaults
let encodedTimezone = NSKeyedArchiver.archivedData(withRootObject: timezone1)
let encodedTimezone = NSKeyedArchiver.clocker_archive(with: timezone1)
DataStore.shared().setTimezones([encodedTimezone])
subject?.setupMenubarTimer()

2
Clocker/ClockerUnitTests/StandardMenubarHandlerTests.swift

@ -31,7 +31,7 @@ class StandardMenubarHandlerTests: XCTestCase {
at index: Int = -1)
{
var defaults = store.timezones()
let encodedObject = NSKeyedArchiver.archivedData(withRootObject: object as Any)
let encodedObject = NSKeyedArchiver.clocker_archive(with: object as Any)
index == -1 ? defaults.append(encodedObject) : defaults.insert(encodedObject, at: index)
store.setTimezones(defaults)
}

6
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -27,7 +27,11 @@ public enum DateFormat {
}
// Non-class type cannot conform to NSCoding!
public class TimezoneData: NSObject, NSCoding {
public class TimezoneData: NSObject, NSCoding, NSSecureCoding {
public static var supportsSecureCoding: Bool {
return true
}
public enum SelectionType: Int {
case city
case timezone

2
Clocker/Overall App/DataStore.swift

@ -128,7 +128,7 @@ class DataStore: NSObject {
}
func addTimezone(_ timezone: TimezoneData) {
let encodedTimezone = NSKeyedArchiver.archivedData(withRootObject: timezone)
let encodedTimezone = NSKeyedArchiver.clocker_archive(with: timezone)
var defaults: [Data] = timezones()
defaults.append(encodedTimezone)

13
Clocker/Overall App/Foundation + Additions.swift

@ -56,3 +56,16 @@ public extension Data {
}
}
}
extension NSKeyedArchiver {
static func clocker_archive(with object: Any) -> Data {
if #available(macOS 10.14, *) {
return try! NSKeyedArchiver.archivedData(withRootObject: object, requiringSecureCoding: true)
}
if #available(macOS 10.13, *) {
return NSKeyedArchiver.archivedData(withRootObject: object)
}
}
}

2
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -421,7 +421,7 @@ extension TimezoneDataOperations {
func saveObject(at index: Int = -1) {
var defaults = store.timezones()
let encodedObject = NSKeyedArchiver.archivedData(withRootObject: dataObject as Any)
let encodedObject = NSKeyedArchiver.clocker_archive(with:dataObject as Any)
index == -1 ? defaults.append(encodedObject) : defaults.insert(encodedObject, at: index)
store.setTimezones(defaults)
}

4
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -316,7 +316,7 @@ class NotesPopover: NSViewController {
private func insertTimezoneInDefaultPreferences() {
guard let model = dataObject, var timezones = timezoneObjects else { return }
let encodedObject = NSKeyedArchiver.archivedData(withRootObject: model)
let encodedObject = NSKeyedArchiver.clocker_archive(with:model)
timezones[currentRow] = encodedObject
DataStore.shared().setTimezones(timezones)
}
@ -341,7 +341,7 @@ class NotesPopover: NSViewController {
var datas: [Data] = []
for updatedObject in timezoneObjects {
let dataObject = NSKeyedArchiver.archivedData(withRootObject: updatedObject)
let dataObject = NSKeyedArchiver.clocker_archive(with: updatedObject)
datas.append(dataObject)
}

2
Clocker/Panel/ParentPanelController.swift

@ -285,7 +285,7 @@ class ParentPanelController: NSWindowController {
var datas: [Data] = []
for updatedObject in timezoneObjects {
let dataObject = NSKeyedArchiver.archivedData(withRootObject: updatedObject)
let dataObject = NSKeyedArchiver.clocker_archive(with: updatedObject)
datas.append(dataObject)
}

4
Clocker/Preferences/General/PreferencesDataSource.swift

@ -42,7 +42,7 @@ extension PreferencesDataSource: NSTableViewDelegate {
}
func tableView(_: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
let data = NSKeyedArchiver.archivedData(withRootObject: rowIndexes)
let data = NSKeyedArchiver.clocker_archive(with: rowIndexes)
pboard.declareTypes([.dragSession], owner: self)
pboard.setData(data, forType: .dragSession)
@ -184,7 +184,7 @@ extension PreferencesDataSource: NSTableViewDataSource {
}
private func insert(timezone: TimezoneData, at index: Int) {
let encodedObject = NSKeyedArchiver.archivedData(withRootObject: timezone)
let encodedObject = NSKeyedArchiver.clocker_archive(with: timezone)
var newDefaults = selectedTimezones
newDefaults[index] = encodedObject
store.setTimezones(newDefaults)

Loading…
Cancel
Save