2 // JSONViewCommand.swift
5 // Created by Hori,Masaki on 2017/01/19.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
13 class JSONViewCommand: JSONCommand {
14 let jsonTree: [JSONNode]?
15 let parameterList: [Any]
16 let recieveDate: Date?
17 let command: JSONCommand
19 init(apiResponse: APIResponse, command: JSONCommand) {
20 self.recieveDate = Date()
21 self.parameterList = apiResponse.argumentArray
22 self.jsonTree = JSONNode
23 .nodeWithJSON(apiResponse.json as AnyObject?)
25 self.command = command
26 super.init(apiResponse: apiResponse)
29 required init(apiResponse: APIResponse) {
30 fatalError("use init(apiResponse:command:)")
33 override func execute() {
38 print("JSONTracker Cought Exception -> \(error)")
41 guard let _ = jsonTree else { return print("jsonTree is nil.") }
42 guard let _ = recieveDate else { return print("recieveDate is nil.") }
44 DispatchQueue.main.async {
45 guard let appDelegate = NSApplication.shared().delegate as? AppDelegate
46 else { return print("Can not get AppDelegate") }
47 let commands: [String:Any] = [
49 "argument": self.parameterList,
50 "json": self.jsonTree ?? [],
51 "recieveDate": self.recieveDate ?? Date(),
54 appDelegate.jsonViewWindowController?.setCommand(commands as NSDictionary)