Skip to content

Commit

Permalink
deal with NSFetchedResultsController .Move event as delete and insert…
Browse files Browse the repository at this point in the history
… event to trigger update event for UITableView and UICollectionView.
  • Loading branch information
DenTelezhkin committed Jun 30, 2016
1 parent d153545 commit 37d010c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.6.2](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.6.2)

### Fixed

* `CoreDataStorage` now properly updates new indexPath after Move event on iOS 9.

## [2.6.1](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.6.1)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion DTModelStorage.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DTModelStorage'
s.version = '2.6.1'
s.version = '2.6.2'
s.license = 'MIT'
s.summary = 'Storage classes for datasource based controls.'
s.homepage = 'https://github.com/DenHeadless/DTModelStorage'
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/CoreDataStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public class CoreDataStorage : BaseStorage, StorageProtocol, SupplementaryStorag
case .Move:
if indexPath != nil && newIndexPath != nil {
if indexPath != newIndexPath {
self.currentUpdate?.movedRowIndexPaths.append([indexPath!,newIndexPath!])
self.currentUpdate?.deletedRowIndexPaths.insert(indexPath!)
self.currentUpdate?.insertedRowIndexPaths.insert(newIndexPath!)
}
else {
self.currentUpdate?.updatedRowIndexPaths.insert(indexPath!)
Expand Down
5 changes: 2 additions & 3 deletions Tests/Specs/CoreDataStorageTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class CoreDataStorageTestCase: XCTestCase {
item1.value = 3
let _ = try? item1.managedObjectContext?.save()

let expectedMovement = [[indexPath(0, 0),indexPath(1, 0)]]

expect(self.updateObserver.update?.movedRowIndexPaths).toEventually(equal(expectedMovement))
expect(self.updateObserver.update?.insertedRowIndexPaths).toEventually(equal(Set([indexPath(1, 0)])))
expect(self.updateObserver.update?.deletedRowIndexPaths).toEventually(equal(Set([indexPath(0, 0)])))
}

func testUpdatingValues()
Expand Down

0 comments on commit 37d010c

Please sign in to comment.