Because this project main goal is to provide storage classes and mapping/event functionality for DTCollectionViewManager and DTTableViewManager, you should probably first read, why those two frameworks exist in the first place. This is described, for example, in Why document of DTCollectionViewManager.
- Xcode 12+
- Swift 5.3+
- iOS 11+ / tvOS 11+ / macCatalyst 13+
Swift Package Manager
- Add package into Project settings -> Swift Packages
The goal of storage classes is to provide datasource models for UITableView/UICollectionView. Let's take UITableView, for example. It's datasource methods mostly relates on following:
- items in sections
- section headers and footers / supplementary views
Storage protocol builds upon those elements to define common interface for all storage classes.
SupplementaryStorage protocol extends
Storage to provide methods on supplementary models / headers/ footers.
Here are five
Storage implementations provided by
DTModelStorage and links to detailed documentation on them:
- Memory storage
- Single section storage
- Storage for diffable datasources ( iOS 13 / tvOS 13 and higher )
- CoreData storage
- Realm storage
Please note, that all five storages support the same interface for handling supplementary models - supplementary providers. You can read more about them in dedicated document.
ViewModelMapping and EventReaction
EventReaction classes are a part of mapping system between data models and reusable views. You can read about how they are used and why in DTCollectionViewManager Mapping document as well as DTCollectionViewManager Events document
You may find interesting
9.0.0-beta.1 - 2020-09-02 10:23:50
ViewModelMapping.modelConditionmethod, that allows to create custom mapping condition, but infers model type from mapping. Behavior of this method is identical to
ModelTransfer.modelConditionmethod, except that new method does not require cell or view to implement
MemoryStorage.insertItems(_:at:)method, that allows inserting collection starting from provided indexPath. This is useful, for example, if you are using pagination, and want to insert new page of items between old pages and loading indicator.
This release requires Swift 5.3.
Some context: this release heavily relies on where clauses on contextually generic declarations, that are only available in Swift 5.3 - SE-0267.
- DTModelStorage/Realm subspec requires RealmSwift 5.2 and higher for minimum iOS 9 deployment target.
ViewModelMappinghas been reworked to generic class to capture both View and Model type.
ViewModelMappingProtocolprotocol has been introduced to represent type-erased interface for
ViewModelMappingProtocolinstances can be stored in array, and be called without generic information.
EventReactionclass has been reworked to not contain
ViewModelMappingclass will now instead have an array of
EventReactioninstances attached to it. This way it's now possible to restrict events to only happen if current
ViewModelMappingis compatible for requested model/view/location/mapping condition.
eventsViewMappinghave been removed.
mappingCandidatesmethod now returns
performReactionmethods now accept
locationparameter instead of
- Event reactions are moved from extension on
[ViewModelMapping]to static methods on
EventReactiondue to Swift inability to call methods on sequences that contain protocols.
mappingCandidatesmethod has been moved to
EventReactionhas new initializers with more specific names.
insertItems(_:to:)method is no longer throwing. Anomaly is still produced, if count of models differs from count of indexPaths.
MemoryStorage.defersDatasourceUpdatesproperty. Deferring datasource updates and executing them inside of performBatchUpdates block turned out to be the only stable and correct way to apply updates to both UI and datasource. It's highly recommended to leave this property on. It is now deprecated, and may be removed in the future release, maintaining current default behaviour.
SectionModel.setItems(_:)method. Set items directly through
8.1.0 - 2020-07-02 09:25:47
- Deployment targets - iOS 11 / tvOS 11.
- Minimum Swift version required: 5.0
- Realm dependency updated to Realm 5.
Please note, that this framework version source is identical to previous version (apart from some small Realm adjustments), which supports iOS 8 / tvOS 9 / Swift 4.0 and higher.
8.0.0 - 2019-11-08 11:46:01
8.0.0-beta.2 - 2019-09-06 09:28:51
- Added support for Xcode versions, that are older than Xcode 11.
8.0.0-beta.1 - 2019-08-20 09:04:30
This is a major release with some breaking changes, please read DTModelStorage 8.0 Migration Guide
ViewModelMapping, that exposes recommended bundle to be used when searching for resources of given mapping.
- Setter for
ProxyDiffableDataSourceStoragethat serves as a bridge between
DTCollectionViewManagerand diffable datasource classes(
footerModel(forSection:), have been moved to protocol extensions instead of being implemented in
BaseStorageclass. As a consequence,
BaseStorageno longer confirms to HeaderFooterStorage protocol.
Identifiable protocol has been renamed to
EntityIdentifiable protocol to avoid unwanted clashes with
Foundation.Identifiable protocol, that is available on iOS 13 and higher.
Complete rewrite of header/footer/supplementary model handling. Instead of several implementations and model storages, the API now consists of three closure based properties on
SupplementaryStorage protocol :
supplementaryModelProvider. All storage classes implement this protocol (
Storage protocols and classes have been restructured:
HeaderFooterSettablehave been removed
HeaderFooterStoragefunctionality mostly has been merged into new protocol
BaseStoragehas been split into
BaseUpdateDeliveringStoragethat inherits from it.
Several methods continue to work, but are now bridging to new closure-based API:
setSectionFooterModels, as well as new closure-based API do not call reloadData method, as they were doing before. If you need to reset section headers/footers/supplementaries, consider calling
StorageUpdating.storageNeedsReloading() method manually.
All methods that allowed to set header/footer/supplementary models partially, for a specific section or specific supplementary kind, have been made unavailable or removed.
CoreDataStorage now sets
headerModelProvider closure to allow using FetchedResultsController section name as header instead of having arbitrary logic that compared supplementaryKind to
displaySectionNameForSupplementaryKinds property, which is also made unavailable.
Storageprotocol. It is replaced by more perfomant
Sectionprotocol. It is replaced by
7.4.1 - 2019-07-16 14:44:46
ViewModelMapping, that exposes recommended bundle to be used when searching for resources of given mapping.
setItemsForAllSectionsmethod now properly removes all sections prior to setting new ones. This prevents a bug, where old sections could stay, if this method was called with fewer number of sections.
7.4.0 - 2019-06-17 19:43:25
- Support for Swift Package Manager in Xcode 11
- Slightly improved RealmStorage
- Improved StorageUpdate description.
ViewModelMapping.xibNamecan now be changed inside of mapping blocks to allow changing xibName per mapping.
7.3.0 - 2019-04-07 11:30:18
- Support for Swift 5 and Xcode 10.2
ViewModelMappingCustomizingprotocol. Please switch to using mapping conditions instead.
- Support for Xcode 9 and Swift 3
7.2.1 - 2019-03-01 08:18:23
enqueuedDatasourceUpdatesproperty public to allow building custom storages that defer datasource updates.
7.2.0 - 2018-09-25 14:10:11
Single section storage classes with support for automatic diffing.
SingleSectionStorageclasses are now a recommended way of handling items in single section in more powerful way than
Read more about it in README.
Support for Swift 4.2 and Xcode 10.
Convenience methods for conditional mappings and anomalies
- Method to create
MappingConditionfrom ModelTransfer objects
- Ability to silence anomalies using enum or closure
- Method to create
7.1.0 - 2018-06-09 12:39:15
- Anomaly detecting system for various errors in
MemoryStorage. Read more about it in DTTableViewManager Anomaly Handler Readme section. Anomaly handler system requires Swift 4.1 and higher.
- Support for Xcode 10 (beta 1) with Swift 4.1 and Swift 4.2.
- Crash that could happen if move operation for
MemoryStoragehappened from and to the same section with not enough items in section.
7.0.3 - 2018-04-02 14:45:56
- Updates for Xcode 9.3 and Swift 4.1
7.0.2 - 2018-02-01 12:07:02
- Properly collect all updates from updateWithoutAnimations block.
7.0.1 - 2018-02-01 11:58:04
- Fixed a bug, that prevented datasource from being updated when
7.0.0 - 2018-01-19 15:50:03
7.0.0-beta.1 - 2017-12-04 12:07:02
- Implemented mechanism for deferring datasource updates of
MemoryStorage. When turned on, updates are no longer applied automatically, but can be applied calling
StorageUpdate.applyDeferredDatasourceUpdates()method. Keep in mind, that not only datasource updates are not applied, but object and section changes are also empty until updates are applied. This behaviour is turned on by default, to disable it, call
MemoryStorage.defersDatasourceUpdates = false
- Ream podspec now requires
6.0.0 - 2017-11-01 12:08:58
- Fixed warnings for Xcode 9.1 / Swift 4.0.2
6.0.0-beta.2 - 2017-09-27 14:48:20
- Build with Xcode 9.0 release.
6.0.0-beta.1 - 2017-09-10 17:43:32
This is major release, containing breaking API changes, please read DTTableViewManager 6.0 Migration Guide
MemoryStoragenow has a convenience method for moving item without animations:
EventReactionclass now has 4 and 5 argument reactions
- All storage protocols are now class-bound.
- Implemented mapping conditions.
ViewModelMappingwas changed to be able to work with mapping blocks.
RealmStorageis not included in Carthage releases.
setItemsmethod, that accepted array of arrays of items to set items for all sections, has been renamed to
setItemsForAllSectionsto provide more clarity and not to clash with
5.1.0 - 2017-06-19 15:12:38
- Swift 3.2 support(Xcode 9 beta 1).
RealmCollectionobjects into section, thus allowing
LinkingObjectsto be used(previously only
Resultsobjects could be used in section).
5.0.1 - 2017-05-29 15:48:31
- Improved handling of
NSFetchedResultsChangeType.updatechange type in cases, where object inserts/removal/moves is used simultaneously with object updates(#17).
5.0.0 - 2017-04-06 15:01:29
EventReactionclass to use
ViewModelMappingto properly identify not only model and
ViewType, but also
viewClass. This allows event reactions to run for cases where two view subclasses, conforming to
ModelTransfer, use the same model, and have similar events.
4.1.0 - 2017-01-29 09:18:47
setItems(_:)method, that allows to set items for all sections in
4.0.0 - 2016-10-28 14:29:43
StorageUpdateproperties, that tracked changes independently of each other, have been replaced with
sectionChangesarrays, that track all changes in order they occured
updatedObjectsdictionary, that allow tracking objects, that have been updated, along with corresponding indexPath. It is done because UITableView and UICollectionView defer cell updates after insertions and deletions are completed, and therefore shift indexPaths. For example, if you were to insert 0 item and update it, UITableView would think that you are updating 1 item instead of 0, because it happens in single animation block and 0 item becomes 1.
3.0.0 - 2016-10-23 13:28:04
No changes from previous betas.
3.0.0-beta.3 - 2016-10-13 08:49:37
- Requires Realm 2.0 and higher.
- Fixes crash, that happens, when subscribing to Realm notifications and Realm is read-only(thanks, @augmentedworks!)
3.0.0-beta.2 - 2016-09-24 09:25:57
3.0.0-beta.1 - 2016-09-17 09:37:50
Swift 3.0 and higher is required for this version of framework.
Note. Beta 1 Does not include RealmStorage subspec due to RealmSwift.framework podspec issues
UIReactionclass has been replaced with new
EventReactionclass, that allows more flexible and powerful events usage
- Supplementary models are now stored in
[String:Any]to support supplementary models, whose position is determined by indexPath in UICollectionView.
SupplementaryAccessibleprotocols have been reworked to reflect those changes.
MemoryStorageErrorshave been made an
Errortype following conventions from SE-0112.
SectionLocationIdentifyableprotocol, allowing any section to find out, what it's index is.
currentSectionIndexproperty, that shows index of section in sections array.
CoreDataStorage, that defines, for which supplementary kinds
sectionNameshould be used as a data model.
MemoryStorage, that allows to remove all items from specific section
makeNSIndexSetmethod, because Swift 3 allows to directly create IndexSet from both
2.6.2 - 2016-06-30 13:30:16
CoreDataStoragenow properly updates new indexPath after Move event on iOS 9.
2.6.1 - 2016-05-30 15:44:42
- Now properly handles case, when
deleteSectionsmethod was called with index, that is not present in