Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #162 from AgapovOne/master
Browse files Browse the repository at this point in the history
Fix ambigious use of row and section
  • Loading branch information
vmartinelli authored Dec 3, 2016
2 parents 82fb4f6 + 823b073 commit 62d563a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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
23 changes: 5 additions & 18 deletions Source/AlecrimCoreData/Core/Extensions/UITableViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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

0 comments on commit 62d563a

Please sign in to comment.