Fix some build errors.

This commit is contained in:
Brent Simmons 2017-10-31 20:33:41 -07:00
parent b048e3fd58
commit 69718e2dde
2 changed files with 16 additions and 10 deletions

View File

@ -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
}
}

View File

@ -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