From e58a32423bf15a7cf197709101fecd2976f0ad6d Mon Sep 17 00:00:00 2001 From: Denys Telezhkin Date: Sun, 11 Oct 2015 16:56:50 +0300 Subject: [PATCH] add insert section method, bump podspec --- CHANGELOG.md | 11 ++++++-- DTModelStorage.podspec | 2 +- DTModelStorage/Memory/MemoryStorage.swift | 14 ++++++++++ .../MemoryStorageEditSpecs.swift | 28 ++++++++++++++++++- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 008ab1fe..c8bc5530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,17 @@ # Change Log All notable changes to this project will be documented in this file. +## [2.1.1](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.1.1) + +#### Added +* `insertSection(_:atIndex:)` that allows to insert `SectionModel` directly, with items and supplementary headers. + ## [2.1.0](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.1.0) #### Updated -* `StorageUpdate` class was rewritten from scratch using Swift `Set`. -* `StorageUpdate` now contains `movedRowIndexPaths` and `movedSectionIndexes` properties. +* `StorageUpdate` class was rewritten from scratch using Swift Set. +* `StorageUpdate` now contains movedRowIndexPaths and movedSectionIndexes properties +* All method names and properties, that contained `object` term in their name, have been renamed to read 'item' instead #### Fixed * `removeItems` method should no longer skip items, if their indexPath is reduced when removing previous item @@ -16,7 +22,6 @@ All notable changes to this project will be documented in this file. * `moveCollectionViewSection:toSection` and `moveTableViewSection:toSection` have been replaced by `moveSection:toSection` method ## [2.0.0](https://github.com/DenHeadless/DTModelStorage/releases/tag/2.0.0) -Released on 2015-09-13. Framework was completely rewritten from scratch in Swift 2. diff --git a/DTModelStorage.podspec b/DTModelStorage.podspec index 2d86bf90..26fc5cc0 100644 --- a/DTModelStorage.podspec +++ b/DTModelStorage.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'DTModelStorage' - s.version = '2.1.0' + s.version = '2.1.1' s.license = 'MIT' s.summary = 'Storage classes for datasource based controls.' s.homepage = 'https://github.com/DenHeadless/DTModelStorage' diff --git a/DTModelStorage/Memory/MemoryStorage.swift b/DTModelStorage/Memory/MemoryStorage.swift index 32f7421c..9bfdcb58 100644 --- a/DTModelStorage/Memory/MemoryStorage.swift +++ b/DTModelStorage/Memory/MemoryStorage.swift @@ -152,6 +152,20 @@ public class MemoryStorage: BaseStorage, StorageProtocol self.delegate?.storageNeedsReloading() } + /// Insert section. This method is assumed to be used, when you need to insert section with items and supplementaries in one batch operation. If you need to simply add items, use `addItems` or `setItems` instead. + /// - Parameter section: section to insert + /// - Parameter atIndex: index of section to insert. If `atIndex` is larger than number of sections, method does nothing. + public func insertSection(section: SectionModel, atIndex sectionIndex: Int) { + guard sectionIndex <= sections.count else { return } + startUpdate() + sections.insert(section, atIndex: sectionIndex) + currentUpdate?.insertedSectionIndexes.insert(sectionIndex) + for item in 0..