From 69718e2dde3122667914aad6a6a23a6f7e8ed993 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 31 Oct 2017 20:33:41 -0700 Subject: [PATCH] Fix some build errors. --- .../Timeline/TimelineTableViewDataSource.swift | 8 ++++---- .../Timeline/TimelineViewController.swift | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift b/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift index 050f7d293..3ef05d89b 100644 --- a/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift +++ b/Evergreen/MainWindow/Timeline/TimelineTableViewDataSource.swift @@ -6,9 +6,9 @@ // Copyright © 2017 Ranchero Software. All rights reserved. // -import Foundation +import Cocoa -final class TimelineTableViewDataSource { +@objc final class TimelineTableViewDataSource: NSObject, NSTableViewDataSource { private weak var timelineViewController: TimelineViewController? @@ -21,12 +21,12 @@ final class TimelineTableViewDataSource { func numberOfRows(in tableView: NSTableView) -> Int { - return timelineViewController?.articles.count ? 0 + return timelineViewController?.numberOfArticles ?? 0 } func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? { - return timelineViewController?.articleAtRow(row) ? nil + return timelineViewController?.articleAtRow(row) ?? nil } } diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index 6b5cbf6d6..6682052f4 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -26,6 +26,12 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView } var cellAppearance: TimelineCellAppearance! + var numberOfArticles: Int { + get { + return articles.count + } + } + private var articles = [Article]() { didSet { if articles != oldValue { @@ -239,16 +245,16 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView return nil } - var ix = tableView.selectedRow + var rowIndex = tableView.selectedRow while(true) { - ix = ix + 1 - if ix >= articles.count { + rowIndex = rowIndex + 1 + if rowIndex >= articles.count { break } - let article = articleAtRow(ix)! + let article = articleAtRow(rowIndex)! if !article.status.read { - return ix + return rowIndex } } @@ -389,7 +395,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView }) } - private func articleAtRow(_ row: Int) -> Article? { + func articleAtRow(_ row: Int) -> Article? { if row < 0 || row == NSNotFound || row > articles.count - 1 { return nil