From c2817294988c8c53c63dcc35e1736aa5929227f6 Mon Sep 17 00:00:00 2001 From: Vladimir Lyukov Date: Thu, 24 Nov 2016 11:41:23 +0300 Subject: [PATCH] Duplicated IndexPath extension to NSIndexPath For Objective-C usage --- Source/Utility/IndexPath+DataGrid.swift | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Source/Utility/IndexPath+DataGrid.swift b/Source/Utility/IndexPath+DataGrid.swift index 062506b..b3eecae 100644 --- a/Source/Utility/IndexPath+DataGrid.swift +++ b/Source/Utility/IndexPath+DataGrid.swift @@ -38,3 +38,33 @@ public extension IndexPath { return self[0] } } + + +public extension NSIndexPath { + /** + Returns an index-path object initialized with the indexes of a specific row and column in a data grid view. + + - parameter column: An index number identifying a column in a DataGridView object in a row identified by the row parameter. + - parameter row: An index number identifying a row in a DataGridView object. + + - returns: An NSIndexPath object. + */ + convenience init(forColumn column: Int, row: Int) { + self.init(item: column, section: row) + } + + /// An index number identifying a column in a row of a data grid view. (read-only) + var dataGridColumn: Int { + return self.index(atPosition: 1) + } + + /// An index number identifying a row in a data grid view. (read-only) + var dataGridRow: Int { + return self.index(atPosition: 0) + } + + /// An index number for single-item indexPath + var index: Int { + return self.index(atPosition: 0) + } +}