Skip to content

Commit

Permalink
Update Foundation + Additions.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
n0shake committed Feb 7, 2021
1 parent 9487907 commit 27a609a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Clocker/Overall App/Foundation + Additions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright © 2015 Abhishek Banthia

import Cocoa
import CoreModelKit

extension NSNotification.Name {
static let themeDidChange = NSNotification.Name("ThemeDidChangeNotification")
Expand Down Expand Up @@ -32,3 +33,26 @@ extension NSImage.Name {
static let sortToggleAlternateIcon = NSImage.Name("Additional Preferences Highlighted Dynamic")
static let menubarIcon = NSImage.Name("LightModeIcon")
}

extension Data {
// Extracting this out for tests
public func decode() -> SearchResult? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(SearchResult.self, from: self)
return decodedObject
} catch {
return nil
}
}

public func decodeTimezone() -> Timezone? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(Timezone.self, from: self)
return decodedObject
} catch {
return nil
}
}
}

0 comments on commit 27a609a

Please sign in to comment.