diff --git a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate
index 36804fd..f04cf72 100644
Binary files a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate and b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/OTRS-Watch/Base.lproj/Main.storyboard b/OTRS-Watch/Base.lproj/Main.storyboard
index 9027f86..617e2a7 100644
--- a/OTRS-Watch/Base.lproj/Main.storyboard
+++ b/OTRS-Watch/Base.lproj/Main.storyboard
@@ -729,7 +729,7 @@
-
+
@@ -741,7 +741,7 @@
-
+
diff --git a/OTRS-Watch/Extension/ViewControllerExtension.swift b/OTRS-Watch/Extension/ViewControllerExtension.swift
index b7885b7..0df5f73 100644
--- a/OTRS-Watch/Extension/ViewControllerExtension.swift
+++ b/OTRS-Watch/Extension/ViewControllerExtension.swift
@@ -11,7 +11,7 @@ import Cocoa
extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
fileprivate enum CellIdentifiers {
- static let OTRSTicketNumber = "OTRSTicketNumber"
+ static let OTRSTicketNumber = "OTRSTicketCreated"
static let OTRSTicketOwner = "OTRSTicketOwner"
static let OTRSTicketDetails = "OTRSTicketDetails"
}
@@ -26,14 +26,15 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
var text: String = ""
var cellIdentifier: String = ""
- guard let item:Ticket = OTRS.sharedInstance.ticketDictionary[row] else {
+ guard row < OTRS.sharedInstance.ticketDictionary.count,
+ let item:Ticket = OTRS.sharedInstance.ticketDictionary[row] else {
return nil
}
if tableColumn == self.ticketTableView.tableColumns[0] {
cellIdentifier = CellIdentifiers.OTRSTicketNumber
image = nil
- text = item.ticketNumber
+ text = item.created.description
} else if tableColumn == self.ticketTableView.tableColumns[1] {
cellIdentifier = CellIdentifiers.OTRSTicketDetails
image = nil
@@ -54,13 +55,10 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
}
func tableViewSelectionDidChange(_ notification: Notification) {
- updateViewAfterSelectionDidChange()
- }
-
- private func updateViewAfterSelectionDidChange() {
- let selectedRow = ticketTableView.selectedRow
+ let row = ticketTableView.selectedRow
+ let myTableViewFromNotification = notification.object as! NSTableView
- print(selectedRow)
+ print(myTableViewFromNotification)
}
}
diff --git a/OTRS-Watch/ViewController.swift b/OTRS-Watch/ViewController.swift
index 08a3006..3641221 100644
--- a/OTRS-Watch/ViewController.swift
+++ b/OTRS-Watch/ViewController.swift
@@ -78,13 +78,18 @@ class ViewController: NSViewController {
let _:Ticket = userInfo["ticket"] as? Ticket else {
return
}
- }
-
- func catchTicketsUpdated(notification:Notification) -> Void {
- DispatchQueue.main.async{
- print("\(OTRS.sharedInstance.ticketDictionary.count) tickets to be shown")
+
+ OTRS.sharedInstance.ticketDictionary.sort {
+ $0.created > $1.created
+ }
+
+ DispatchQueue.main.async {
self.ticketTableView.reloadData()
}
}
+
+ func catchTicketsUpdated(notification:Notification) -> Void {
+ print("\(OTRS.sharedInstance.ticketDictionary.count) tickets to be shown")
+ }
}