Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TableViewController: NSViewController {
super.viewDidLoad()

// create data source
let dataSource = RxTableViewRealmDataSource<Lap>(cellIdentifier: "Cell", cellType: NSTableCellView.self) {cell, row, lap in
let dataSource = RxTableViewRealmDataSource<Lap>(cellIdentifier: "Cell", cellType: NSTableCellView.self) {cell, row, columnId, lap in
cell.textField!.stringValue = "\(lap.text)"
}
dataSource.delegate = self
Expand Down
11 changes: 6 additions & 5 deletions Pod/Classes/RxTableViewRealmDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ import RxRealm

import Cocoa

public typealias TableCellFactory<E: Object> = (RxTableViewRealmDataSource<E>, NSTableView, Int, E) -> NSTableCellView
public typealias TableCellConfig<E: Object, CellType: NSTableCellView> = (CellType, Int, E) -> Void
public typealias TableCellFactory<E: Object> = (RxTableViewRealmDataSource<E>, NSTableView, Int, String?, E) -> NSTableCellView
public typealias TableCellConfig<E: Object, CellType: NSTableCellView> = (CellType, Int, String?, E) -> Void

open class RxTableViewRealmDataSource<E: Object>: NSObject, NSTableViewDataSource, NSTableViewDelegate {

Expand Down Expand Up @@ -151,9 +151,9 @@ import RxRealm

public init<CellType>(cellIdentifier: String, cellType: CellType.Type, cellConfig: @escaping TableCellConfig<E, CellType>) where CellType: NSTableCellView {
self.cellIdentifier = cellIdentifier
self.cellFactory = { ds, tv, row, model in
self.cellFactory = { ds, tv, row, columnId, model in
let cell = tv.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: tv) as! CellType
cellConfig(cell, row, model)
cellConfig(cell, row, columnId, model)
return cell
}
}
Expand All @@ -164,7 +164,8 @@ import RxRealm
}

public func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
return cellFactory(self, tableView, row, items![row])
let columnId = tableColumn?.identifier.rawValue
return cellFactory(self, tableView, row, columnId, items![row])
}

// MARK: - Proxy unimplemented data source and delegate methods
Expand Down