From 9d0875a624c9382a3c1216d9ed7de56bb26a75e2 Mon Sep 17 00:00:00 2001 From: Udo von Eynern Date: Mon, 9 Jul 2018 09:35:54 +0200 Subject: [PATCH 1/2] Fixes for Swift 4.1 --- Source/Cells/DataGridViewBaseCell.swift | 2 +- Source/Cells/DataGridViewColumnHeaderCell.swift | 13 +++++++++---- Source/Cells/DataGridViewContentCell.swift | 12 +++++++++--- Source/Cells/DataGridViewRowHeaderCell.swift | 12 +++++++++--- Source/DataGridView.swift | 10 +++------- Source/Utility/IndexPath+DataGrid.swift | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Source/Cells/DataGridViewBaseCell.swift b/Source/Cells/DataGridViewBaseCell.swift index ad1c726..d30dbcb 100644 --- a/Source/Cells/DataGridViewBaseCell.swift +++ b/Source/Cells/DataGridViewBaseCell.swift @@ -12,7 +12,7 @@ import UIKit /** Base class for data grid view cells. */ -open class DataGridViewBaseCell: UICollectionViewCell { +@objcMembers open class DataGridViewBaseCell: UICollectionViewCell { /// The inset or outset margins for the rectangle around the cell’s text label. open dynamic var textLabelInsets = UIEdgeInsets.zero /// Background color for highlighted state. diff --git a/Source/Cells/DataGridViewColumnHeaderCell.swift b/Source/Cells/DataGridViewColumnHeaderCell.swift index af64a84..ca55524 100644 --- a/Source/Cells/DataGridViewColumnHeaderCell.swift +++ b/Source/Cells/DataGridViewColumnHeaderCell.swift @@ -20,7 +20,7 @@ open class DataGridViewColumnHeaderCell: DataGridViewBaseHeaderCell { if let labelAppearance = UILabel.glyuck_appearanceWhenContained(in: DataGridViewColumnHeaderCell.self) { if #available(iOS 8.2, *) { - labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFontWeightRegular) + labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular) } else { labelAppearance.appearanceFont = UIFont(name: "HelveticaNeue", size: 14) } @@ -31,9 +31,14 @@ open class DataGridViewColumnHeaderCell: DataGridViewBaseHeaderCell { } }() - // MARK: - UIView - open override static func initialize() { - super.initialize() + + public override init(frame: CGRect) { + super.init(frame: frame) + _ = DataGridViewColumnHeaderCell.__once + } + + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) _ = DataGridViewColumnHeaderCell.__once } diff --git a/Source/Cells/DataGridViewContentCell.swift b/Source/Cells/DataGridViewContentCell.swift index 06c88a6..7e20b8e 100644 --- a/Source/Cells/DataGridViewContentCell.swift +++ b/Source/Cells/DataGridViewContentCell.swift @@ -17,7 +17,7 @@ open class DataGridViewContentCell: DataGridViewBaseCell { if let labelAppearance = UILabel.glyuck_appearanceWhenContained(in: DataGridViewContentCell.self) { if #available(iOS 8.2, *) { - labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFontWeightLight) + labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.light) } else { labelAppearance.appearanceFont = UIFont(name: "HelveticaNeue-Light", size: 14) } @@ -26,8 +26,14 @@ open class DataGridViewContentCell: DataGridViewBaseCell { } }() - open override static func initialize() { - super.initialize() + + public override init(frame: CGRect) { + super.init(frame: frame) + _ = DataGridViewContentCell.__once + } + + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) _ = DataGridViewContentCell.__once } } diff --git a/Source/Cells/DataGridViewRowHeaderCell.swift b/Source/Cells/DataGridViewRowHeaderCell.swift index 3078c1f..90674ad 100644 --- a/Source/Cells/DataGridViewRowHeaderCell.swift +++ b/Source/Cells/DataGridViewRowHeaderCell.swift @@ -22,7 +22,7 @@ open class DataGridViewRowHeaderCell: DataGridViewBaseHeaderCell { if let labelAppearance = UILabel.glyuck_appearanceWhenContained(in: DataGridViewRowHeaderCell.self) { if #available(iOS 8.2, *) { - labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFontWeightRegular) + labelAppearance.appearanceFont = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular) } else { labelAppearance.appearanceFont = UIFont(name: "HelveticaNeue", size: 14) } @@ -32,8 +32,14 @@ open class DataGridViewRowHeaderCell: DataGridViewBaseHeaderCell { } }() - open override static func initialize() { - super.initialize() + + public override init(frame: CGRect) { + super.init(frame: frame) + _ = DataGridViewRowHeaderCell.__once + } + + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) _ = DataGridViewRowHeaderCell.__once } } diff --git a/Source/DataGridView.swift b/Source/DataGridView.swift index 1a144e7..7ff7d87 100644 --- a/Source/DataGridView.swift +++ b/Source/DataGridView.swift @@ -179,7 +179,7 @@ import UIKit /** An instance of DataGridView (or simply, a data grid view) is a means for displaying and editing data represented in multicolumn tables (or 2-dimension matrices). */ -open class DataGridView: UIView { +@objcMembers open class DataGridView: UIView { private static var __once: () = { let appearance = DataGridView.appearance() appearance.row1BackgroundColor = UIColor(white: 0.95, alpha: 1) @@ -468,19 +468,15 @@ open class DataGridView: UIView { } // UIView - - open override static func initialize() { - super.initialize() - _ = DataGridView.__once - } - public override init(frame: CGRect) { super.init(frame: frame) + _ = DataGridView.__once setupDataGridView() } public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) + _ = DataGridView.__once setupDataGridView() } diff --git a/Source/Utility/IndexPath+DataGrid.swift b/Source/Utility/IndexPath+DataGrid.swift index b3eecae..9c54cad 100644 --- a/Source/Utility/IndexPath+DataGrid.swift +++ b/Source/Utility/IndexPath+DataGrid.swift @@ -40,7 +40,7 @@ public extension IndexPath { } -public extension NSIndexPath { +@objc public extension NSIndexPath { /** Returns an index-path object initialized with the indexes of a specific row and column in a data grid view. From a524fe9a2ca39bbfb8932968025aea384350e8f5 Mon Sep 17 00:00:00 2001 From: Udo von Eynern Date: Thu, 11 Oct 2018 18:09:11 +0200 Subject: [PATCH 2/2] Fixes for Swift 4.2 --- Source/Cells/DataGridViewBaseCell.swift | 2 +- Source/DataGridView.swift | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Cells/DataGridViewBaseCell.swift b/Source/Cells/DataGridViewBaseCell.swift index d30dbcb..1423b67 100644 --- a/Source/Cells/DataGridViewBaseCell.swift +++ b/Source/Cells/DataGridViewBaseCell.swift @@ -47,7 +47,7 @@ import UIKit open override func layoutSubviews() { super.layoutSubviews() - textLabel.frame = UIEdgeInsetsInsetRect(bounds, textLabelInsets) + textLabel.frame = bounds.inset(by: textLabelInsets) } open override func layoutSublayers(of layer: CALayer) { diff --git a/Source/DataGridView.swift b/Source/DataGridView.swift index 7ff7d87..6d50ad4 100644 --- a/Source/DataGridView.swift +++ b/Source/DataGridView.swift @@ -334,7 +334,7 @@ import UIKit collectionView.indexPathsForSelectedItems?.forEach { collectionView.deselectItem(at: $0, animated: animated) } for column in 0..