From 823b0737416544bd78999b60830cf40d3c2415fb Mon Sep 17 00:00:00 2001 From: Aleksey Agapov Date: Fri, 18 Nov 2016 12:00:54 +0500 Subject: [PATCH] Fix ambigious use of row and section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After convertion to swift 3 we don’t need extensions anymore, but they make non-framework code ambigious for rows and sections. Fixed using init(item:section:) and init(row:section:) for tableView and collectionView. --- .../UICollectionViewExtensions.swift | 24 ++++--------------- .../Extensions/UITableViewExtensions.swift | 23 ++++-------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/Source/AlecrimCoreData/Core/Extensions/UICollectionViewExtensions.swift b/Source/AlecrimCoreData/Core/Extensions/UICollectionViewExtensions.swift index 05607c9..7239a4e 100644 --- a/Source/AlecrimCoreData/Core/Extensions/UICollectionViewExtensions.swift +++ b/Source/AlecrimCoreData/Core/Extensions/UICollectionViewExtensions.swift @@ -67,7 +67,7 @@ } .didInsertObject { entity, newIndexPath in if !reloadData { - let newIndexPath = sectionOffset > 0 ? IndexPath(forItem: newIndexPath.item, inSection: newIndexPath.section + sectionOffset) : newIndexPath + let newIndexPath = sectionOffset > 0 ? IndexPath(item: newIndexPath.item, section: newIndexPath.section + sectionOffset) : newIndexPath if !insertedSectionIndexes.contains(newIndexPath.section) { insertedItemIndexPaths.append(newIndexPath) @@ -76,7 +76,7 @@ } .didDeleteObject { entity, indexPath in if !reloadData { - let indexPath = sectionOffset > 0 ? IndexPath(forItem: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let indexPath = sectionOffset > 0 ? IndexPath(item: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if !deletedSectionIndexes.contains(indexPath.section) { deletedItemIndexPaths.append(indexPath) @@ -85,7 +85,7 @@ } .didUpdateObject { entity, indexPath in if !reloadData { - let indexPath = sectionOffset > 0 ? IndexPath(forItem: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let indexPath = sectionOffset > 0 ? IndexPath(item: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if !deletedSectionIndexes.contains(indexPath.section) && deletedItemIndexPaths.index(of: indexPath) == nil && updatedItemIndexPaths.index(of: indexPath) == nil { updatedItemIndexPaths.append(indexPath) @@ -94,8 +94,8 @@ } .didMoveObject { entity, indexPath, newIndexPath in if !reloadData { - let newIndexPath = sectionOffset > 0 ? IndexPath(forItem: newIndexPath.item, inSection: newIndexPath.section + sectionOffset) : newIndexPath - let indexPath = sectionOffset > 0 ? IndexPath(forItem: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let newIndexPath = sectionOffset > 0 ? IndexPath(item: newIndexPath.item, section: newIndexPath.section + sectionOffset) : newIndexPath + let indexPath = sectionOffset > 0 ? IndexPath(item: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if newIndexPath == indexPath { if !deletedSectionIndexes.contains(indexPath.section) && deletedItemIndexPaths.index(of: indexPath) == nil && updatedItemIndexPaths.index(of: indexPath) == nil { @@ -169,18 +169,4 @@ } - // MARK: - IndexPath extensions - - extension IndexPath { - - public init(forItem item: Int, inSection section: Int) { - self.init(indexes: [section, item]) - } - - public var section: Int { return self[0] } - public var item: Int { return self[1] } - - } - - #endif diff --git a/Source/AlecrimCoreData/Core/Extensions/UITableViewExtensions.swift b/Source/AlecrimCoreData/Core/Extensions/UITableViewExtensions.swift index a86532e..e8a9483 100644 --- a/Source/AlecrimCoreData/Core/Extensions/UITableViewExtensions.swift +++ b/Source/AlecrimCoreData/Core/Extensions/UITableViewExtensions.swift @@ -68,7 +68,7 @@ } .didInsertObject { entity, newIndexPath in if !reloadData { - let newIndexPath = sectionOffset > 0 ? IndexPath(forRow: newIndexPath.item, inSection: newIndexPath.section + sectionOffset) : newIndexPath + let newIndexPath = sectionOffset > 0 ? IndexPath(row: newIndexPath.item, section: newIndexPath.section + sectionOffset) : newIndexPath if !insertedSectionIndexes.contains(newIndexPath.section) { insertedItemIndexPaths.append(newIndexPath) @@ -77,7 +77,7 @@ } .didDeleteObject { entity, indexPath in if !reloadData { - let indexPath = sectionOffset > 0 ? IndexPath(forRow: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let indexPath = sectionOffset > 0 ? IndexPath(row: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if !deletedSectionIndexes.contains(indexPath.section) { deletedItemIndexPaths.append(indexPath) @@ -86,7 +86,7 @@ } .didUpdateObject { entity, indexPath in if !reloadData { - let indexPath = sectionOffset > 0 ? IndexPath(forRow: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let indexPath = sectionOffset > 0 ? IndexPath(row: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if !deletedSectionIndexes.contains(indexPath.section) && deletedItemIndexPaths.index(of: indexPath) == nil && updatedItemIndexPaths.index(of: indexPath) == nil { updatedItemIndexPaths.append(indexPath) @@ -95,8 +95,8 @@ } .didMoveObject { entity, indexPath, newIndexPath in if !reloadData { - let newIndexPath = sectionOffset > 0 ? IndexPath(forRow: newIndexPath.item, inSection: newIndexPath.section + sectionOffset) : newIndexPath - let indexPath = sectionOffset > 0 ? IndexPath(forRow: indexPath.item, inSection: indexPath.section + sectionOffset) : indexPath + let newIndexPath = sectionOffset > 0 ? IndexPath(row: newIndexPath.item, section: newIndexPath.section + sectionOffset) : newIndexPath + let indexPath = sectionOffset > 0 ? IndexPath(row: indexPath.item, section: indexPath.section + sectionOffset) : indexPath if newIndexPath == indexPath { if !deletedSectionIndexes.contains(indexPath.section) && deletedItemIndexPaths.index(of: indexPath) == nil && updatedItemIndexPaths.index(of: indexPath) == nil { @@ -176,17 +176,4 @@ } - // MARK: - IndexPath extensions - - extension IndexPath { - - public init(forRow row: Int, inSection section: Int) { - self.init(indexes: [section, row]) - } - - //public var section: Int { return self[0] } - public var row: Int { return self[1] } - - } - #endif