 import Foundation
 import AppKit
 
+private func memoryAddress(object: AnyObject) -> String {
+	let ptr = Unmanaged<AnyObject>.passUnretained(object).toOpaque()
+	return "\(ptr)"
+}
+
 private let defaultRowHeight: CGFloat = 42
 
 private class FewListCell: NSTableCellView {

	}

	func parentKeyForCell(cell: FewListCell) -> String {
		let ptr = Unmanaged<AnyObject>.passUnretained(cell).toOpaque()
		return "\(ptr)"
	}

	@objc func tableView(tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
		let height = NSHeight(elements[row].frame)
		return height > CGFloat(0) ? height : defaultRowHeight
	}

	@objc func tableViewSelectionIsChanging(notification: NSNotification) {


		scrollView.documentView = tableView

		scrollView.handler = TableViewHandler(tableView: tableView, elements: elements)
		scrollView.handler?.selectionChanged = selectionChanged
		
		return scrollView
	}

	public override func elementDidLayout(realizedSelf: RealizedElement?) {
		super.elementDidLayout(realizedSelf)

		if let scrollView = realizedSelf?.view as? FewScrollView {
			let handler = scrollView.handler

			handler?.elements = elements
		}
	}
}
