do {
let data = try Data(contentsOf: url)
let array = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data as NSData)
+ guard let commands = array as? [[String: Any]]
+ else { return }
self.logedJSONViewWindowController = JSONViewWindowController()
- self.logedJSONViewWindowController?.commands = array as! NSMutableArray
+ self.logedJSONViewWindowController?.commands = commands
self.logedJSONViewWindowController?.window?.title = "SAVED LOG FILE VIEWER"
self.logedJSONViewWindowController?.showWindow(nil)
}
guard let _ = recieveDate else { return print("recieveDate is nil.") }
DispatchQueue.main.async {
- let commands: [String:Any] = [
+ let commands: [String: Any] = [
"api": self.api,
"argument": self.parameterList,
"json": self.jsonTree ?? [],
"recieveDate": self.recieveDate ?? Date(),
"date": Date()
]
- AppDelegate.shared.jsonViewWindowController?.setCommand(commands as NSDictionary)
+ AppDelegate.shared.jsonViewWindowController?.setCommand(commands)
}
}
}
var arguments: NSArray?
var json: AnyObject?
- var commands: NSMutableArray = []
+ var commands: [[String: Any]] = []
override func windowDidLoad() {
super.windowDidLoad()
bind("json", to: apis, withKeyPath: "selection.json")
}
- func setCommand(_ command: NSDictionary) {
+ func setCommand(_ command: [String: Any]) {
willChangeValue(forKey: "commands")
- commands.add(command)
- didChangeValue(forKey: "commands")
- }
- func setCommandArray(_ commands: NSArray) {
- willChangeValue(forKey: "commands")
- self.commands.addObjects(from: commands as! [Any])
+ commands += [command]
didChangeValue(forKey: "commands")
}
+// func setCommandArray(_ commands: NSArray) {
+// willChangeValue(forKey: "commands")
+// self.commands.addObjects(from: commands as! [Any])
+// didChangeValue(forKey: "commands")
+// }
@IBAction func clearLog(_ sender: AnyObject?) {
willChangeValue(forKey: "commands")
- commands.removeAllObjects()
+ commands = []
didChangeValue(forKey: "commands")
}
}