2016-11-23 20:42:52 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< title > Migration Reference< / title >
< link rel = "stylesheet" type = "text/css" href = "css/jazzy.css" / >
< link rel = "stylesheet" type = "text/css" href = "css/highlight.css" / >
< meta charset = 'utf-8' >
< script src = "js/jquery.min.js" defer > < / script >
< script src = "js/jazzy.js" defer > < / script >
< / head >
< body >
< a title = "Migration Reference" > < / a >
< header >
< div class = "content-wrapper" >
2017-08-23 21:12:05 +00:00
< p > < a href = "index.html" > IGListKit Docs< / a > (98% documented)< / p >
2016-11-23 20:42:52 +00:00
< p class = "header-right" > < a href = "https://github.com/Instagram/IGListKit" > < img src = "img/gh.png" / > View on GitHub< / a > < / p >
< / div >
< / header >
< div class = "content-wrapper" >
< p id = "breadcrumbs" >
< a href = "index.html" > IGListKit Reference< / a >
< img id = "carat" src = "img/carat.png" / >
Migration Reference
< / p >
< / div >
< div class = "content-wrapper" >
< nav class = "sidebar" >
< ul class = "nav-groups" >
< li class = "nav-group-name" >
< a href = "Guides.html" > Guides< / a >
< ul class = "nav-group-tasks" >
2017-05-12 14:19:12 +00:00
< li class = "nav-group-task" >
< a href = "best-practices-and-faq.html" > Best Practices and FAQ< / a >
< / li >
2018-04-23 16:27:43 +00:00
< li class = "nav-group-task" >
< a href = "generating-your-models.html" > Generating your models< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "getting-started.html" > Getting Started< / a >
< / li >
2016-11-28 00:53:20 +00:00
< li class = "nav-group-task" >
< a href = "iglistdiffable-and-equality.html" > IGListDiffable and Equality< / a >
< / li >
2016-12-27 20:37:57 +00:00
< li class = "nav-group-task" >
< a href = "installation.html" > Installation< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "migration.html" > Migration< / a >
< / li >
2017-08-23 21:12:05 +00:00
< li class = "nav-group-task" >
< a href = "modeling-and-binding.html" > Modeling and Binding< / a >
< / li >
2017-05-12 14:19:12 +00:00
< li class = "nav-group-task" >
< a href = "vision.html" > VISION< / a >
< / li >
< li class = "nav-group-task" >
< a href = "working-with-core-data.html" > Working with Core Data< / a >
< / li >
< li class = "nav-group-task" >
< a href = "working-with-uicollectionview.html" > Working with UICollectionView< / a >
< / li >
2016-11-23 20:42:52 +00:00
< / ul >
< / li >
< li class = "nav-group-name" >
< a href = "Classes.html" > Classes< / a >
< ul class = "nav-group-tasks" >
< li class = "nav-group-task" >
< a href = "Classes/IGListAdapter.html" > IGListAdapter< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListAdapterUpdater.html" > IGListAdapterUpdater< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListBatchUpdateData.html" > IGListBatchUpdateData< / a >
< / li >
< li class = "nav-group-task" >
2017-05-12 14:19:12 +00:00
< a href = "Classes/IGListBindingSectionController.html" > IGListBindingSectionController< / a >
2016-11-23 20:42:52 +00:00
< / li >
2018-02-06 23:42:25 +00:00
< li class = "nav-group-task" >
< a href = "Classes/IGListCollectionView.html" > IGListCollectionView< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
2017-05-12 14:19:12 +00:00
< a href = "Classes/IGListCollectionViewLayout.html" > IGListCollectionViewLayout< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListGenericSectionController.html" > IGListGenericSectionController< / a >
2016-11-23 20:42:52 +00:00
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListIndexPathResult.html" > IGListIndexPathResult< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListIndexSetResult.html" > IGListIndexSetResult< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListMoveIndex.html" > IGListMoveIndex< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListMoveIndexPath.html" > IGListMoveIndexPath< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes.html#/c:objc(cs)IGListReloadDataUpdater" > IGListReloadDataUpdater< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListSectionController.html" > IGListSectionController< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListSingleSectionController.html" > IGListSingleSectionController< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Classes/IGListStackedSectionController.html" > IGListStackedSectionController< / a >
< / li >
< / ul >
< / li >
< li class = "nav-group-name" >
< a href = "Constants.html" > Constants< / a >
< ul class = "nav-group-tasks" >
< li class = "nav-group-task" >
< a href = "Constants.html#/c:@IGListKitVersionNumber" > IGListKitVersionNumber< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Constants.html#/c:@IGListKitVersionString" > IGListKitVersionString< / a >
< / li >
< / ul >
< / li >
< li class = "nav-group-name" >
2018-02-06 23:42:25 +00:00
< a href = "Enums.html" > Enumerations< / a >
2016-11-23 20:42:52 +00:00
< ul class = "nav-group-tasks" >
2018-02-06 23:42:25 +00:00
< li class = "nav-group-task" >
< a href = "Enums/IGListAdapterUpdateType.html" > IGListAdapterUpdateType< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Enums/IGListDiffOption.html" > IGListDiffOption< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Enums/IGListExperiment.html" > IGListExperiment< / a >
< / li >
< / ul >
< / li >
< li class = "nav-group-name" >
< a href = "Protocols.html" > Protocols< / a >
< ul class = "nav-group-tasks" >
< li class = "nav-group-task" >
< a href = "Protocols/IGListAdapterDataSource.html" > IGListAdapterDataSource< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListAdapterDelegate.html" > IGListAdapterDelegate< / a >
< / li >
2018-04-23 16:27:43 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListAdapterMoveDelegate.html" > IGListAdapterMoveDelegate< / a >
< / li >
2018-02-06 23:42:25 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListAdapterUpdateListener.html" > IGListAdapterUpdateListener< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListAdapterUpdaterDelegate.html" > IGListAdapterUpdaterDelegate< / a >
< / li >
2017-05-12 14:19:12 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListBatchContext.html" > IGListBatchContext< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListBindable.html" > IGListBindable< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListBindingSectionControllerDataSource.html" > IGListBindingSectionControllerDataSource< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListBindingSectionControllerSelectionDelegate.html" > IGListBindingSectionControllerSelectionDelegate< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListCollectionContext.html" > IGListCollectionContext< / a >
< / li >
2018-02-06 23:42:25 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListCollectionViewDelegateLayout.html" > IGListCollectionViewDelegateLayout< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListDiffable.html" > IGListDiffable< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListDisplayDelegate.html" > IGListDisplayDelegate< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListScrollDelegate.html" > IGListScrollDelegate< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListSingleSectionControllerDelegate.html" > IGListSingleSectionControllerDelegate< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListSupplementaryViewSource.html" > IGListSupplementaryViewSource< / a >
< / li >
2018-02-06 23:42:25 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListTransitionDelegate.html" > IGListTransitionDelegate< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Protocols/IGListUpdatingDelegate.html" > IGListUpdatingDelegate< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Protocols/IGListWorkingRangeDelegate.html" > IGListWorkingRangeDelegate< / a >
< / li >
< / ul >
< / li >
< li class = "nav-group-name" >
< a href = "Type Definitions.html" > Type Definitions< / a >
< ul class = "nav-group-tasks" >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListUpdatingDelegate.h@T@IGListItemUpdateBlock" > IGListItemUpdateBlock< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListUpdatingDelegate.h@T@IGListObjectTransitionBlock" > IGListObjectTransitionBlock< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListUpdatingDelegate.h@T@IGListReloadUpdateBlock" > IGListReloadUpdateBlock< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListSingleSectionController.h@T@IGListSingleSectionCellConfigureBlock" > IGListSingleSectionCellConfigureBlock< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListSingleSectionController.h@T@IGListSingleSectionCellSizeBlock" > IGListSingleSectionCellSizeBlock< / a >
< / li >
2018-05-01 23:54:35 +00:00
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListUpdatingDelegate.h@T@IGListToObjectBlock" > IGListToObjectBlock< / a >
< / li >
2016-11-23 20:42:52 +00:00
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListAdapter.h@T@IGListUpdaterCompletion" > IGListUpdaterCompletion< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Type Definitions.html#/c:IGListUpdatingDelegate.h@T@IGListUpdatingCompletion" > IGListUpdatingCompletion< / a >
< / li >
< / ul >
< / li >
< li class = "nav-group-name" >
< a href = "Functions.html" > Functions< / a >
< ul class = "nav-group-tasks" >
< li class = "nav-group-task" >
< a href = "Functions.html#/c:@F@IGListDiff" > IGListDiff< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Functions.html#/c:@F@IGListDiffExperiment" > IGListDiffExperiment< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Functions.html#/c:@F@IGListDiffPaths" > IGListDiffPaths< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Functions.html#/c:@F@IGListDiffPathsExperiment" > IGListDiffPathsExperiment< / a >
< / li >
< li class = "nav-group-task" >
< a href = "Functions.html#/c:IGListExperiments.h@F@IGListExperimentEnabled" > IGListExperimentEnabled< / a >
< / li >
< / ul >
< / li >
< / ul >
< / nav >
< article class = "main-content" >
< section >
< section class = "section" >
2017-05-12 14:19:12 +00:00
< h1 id = 'migration' class = 'heading' > Migration< / h1 >
< p > This guide provides details for how to migrate between major versions of < code > IGListKit< / code > .< / p >
< h2 id = 'from-2-x-to-3-x' class = 'heading' > From 2.x to 3.x< / h2 >
< p > For details on all changes in IGListKit 3.0.0, please see the < a href = "https://github.com/Instagram/IGListKit/releases/tag/3.0.0" > release notes< / a > . < / p >
< blockquote >
< p > < strong > NOTE:< / strong > This release contains < em > a lot< / em > of improvements and source-breaking API changes, especially for Swift clients. These are all noted in the full < a href = "https://github.com/Instagram/IGListKit/releases/tag/3.0.0" > release notes< / a > .< / p >
< / blockquote >
< h3 id = 'q-ig-q-prefix-removed-for-swift' class = 'heading' > < q > IG< / q > prefix removed for Swift< / h3 >
2018-02-06 23:42:25 +00:00
< p > We have improved how < code > IGListKit< / code > APIs get imported into Swift. The < code > IG< / code > prefix has been removed for Swift clients. For example, < code > < a href = "Classes/IGListSectionController.html" > IGListSectionController< / a > < / code > becomes < code > ListSectionController< / code > instead. Along with other interoperability improvements, this makes < code > IGListKit< / code > more readable in Swift.< / p >
2017-05-12 14:19:12 +00:00
< p > To migrate, use Xcode’ s Find navigator (command-3), search for < code > IGList< / code > , and replace with < code > List< / code > .< / p >
< h3 id = 'code-iglistsectiontype-code-removed' class = 'heading' > < code > IGListSectionType< / code > removed< / h3 >
2018-02-06 23:42:25 +00:00
< p > In order to make building section controllers even easier, we removed the protocol and absorbed all of the methods into < code > < a href = "Classes/IGListSectionController.html" > IGListSectionController< / a > < / code > with default implementations.< / p >
2017-05-12 14:19:12 +00:00
< ul >
< li > < code > numberOfItems< / code > returns 1 item< / li >
< li > < code > didUpdateToObject:< / code > and < code > didSelectItemAtIndex:< / code > do nothing< / li >
< li > < code > sizeForItemAtIndex:< / code > returns < code > CGSizeZero< / code > < / li >
< li > < code > cellForItemAtIndex:< / code > asserts (you must override this method)< / li >
< / ul >
2018-02-06 23:42:25 +00:00
< p > In Objective-C, all you need to do is find & remove all uses of < code > IGListSectionType< / code > . This includes < code > < a href = "Classes/IGListSectionController.html" > IGListSectionController< / a > < / code > and < code > < a href = "Protocols/IGListAdapterDataSource.html" > IGListAdapterDataSource< / a > < / code > implementations.< / p >
2017-05-12 14:19:12 +00:00
< p > In Swift, you will also need to add < code > override< / code > keywords to all methods.< / p >
< p > The compiler should catch all instances that need fixed.< / p >
2018-02-06 23:42:25 +00:00
< h3 id = 'code-iglistbindingsectioncontroller-code' class = 'heading' > < code > < a href = "Classes/IGListBindingSectionController.html" > IGListBindingSectionController< / a > < / code > < / h3 >
2017-05-12 14:19:12 +00:00
2018-02-06 23:42:25 +00:00
< p > If you were using < code > IGListDiff(...)< / code > < em > inside< / em > a section controller to compute diffs for cells, we recommend that you start using < code > < a href = "Classes/IGListBindingSectionController.html" > IGListBindingSectionController< / a > < / code > which wraps this behavior in an elegant and tested API.< / p >
< h3 id = 'removed-code-iglistcollectionview-code' class = 'heading' > Removed < code > < a href = "Classes/IGListCollectionView.html" > IGListCollectionView< / a > < / code > < / h3 >
2017-05-12 14:19:12 +00:00
< p > You can simply find regex < code > IGListCollectionView([ |\*|\(])< / code > and replace with regex < code > UICollectionView$1< / code > in your project to fix this.< / p >
< p > < img src = "https://raw.githubusercontent.com/Instagram/IGListKit/master/Resources/replace-iglistcollectionview.png" alt = "Replace IGListCollectionView" > < / p >
< h3 id = 'removed-code-iglistgridcollectionviewlayout-code' class = 'heading' > Removed < code > IGListGridCollectionViewLayout< / code > < / h3 >
2018-02-06 23:42:25 +00:00
< p > Start using < code > < a href = "Classes/IGListCollectionViewLayout.html" > IGListCollectionViewLayout< / a > < / code > instead of < code > IGListGridCollectionViewLayout< / code > .< / p >
2017-05-12 14:19:12 +00:00
< ul >
< li > < code > scrollDirection< / code > is not yet supported. If you need horizontal scrolling, please use < code > UICollectionViewFlowLayout< / code > or file an issue.< / li >
< li > Set < code > minimumLineSpacing< / code > on your < a href = "https://github.com/Instagram/IGListKit/blob/master/Source/IGListSectionController.h#L59-L64" > section controllers< / a > instead of the layout< / li >
< li > Set < code > minimumInteritemSpacing< / code > on your < a href = "https://github.com/Instagram/IGListKit/blob/master/Source/IGListSectionController.h#L66-L71" > section controllers< / a > instead of the layout< / li >
2018-02-06 23:42:25 +00:00
< li > Return the size of your cells in < a href = "https://github.com/Instagram/IGListKit/blob/master/Source/IGListSectionController.h#L48" > sizeForItemAtIndex:< / a > instead of setting it on the layout.< / li >
2017-05-12 14:19:12 +00:00
< / ul >
< h3 id = 'item-mutations-must-be-wrapped-in-code-iglistcollectioncontext-performbatchanimated-completion-code' class = 'heading' > Item mutations must be wrapped in < code > -[IGListCollectionContext performBatchAnimated:completion:]< / code > < / h3 >
2018-02-06 23:42:25 +00:00
< p > To fix some rare crashes, all item mutations must now be performed inside a batch block and done on the < code > < a href = "Protocols/IGListBatchContext.html" > IGListBatchContext< / a > < / code > object instead.< / p >
2017-05-12 14:19:12 +00:00
< p > < strong > Objective-C< / strong > < / p >
2018-02-06 23:42:25 +00:00
< pre class = "highlight objective_c" > < code > < span class = "c1" > // OLD< / span >
< span class = "n" > self< / span > < span class = "p" > .< / span > < span class = "n" > expanded< / span > < span class = "o" > =< / span > < span class = "nb" > YES< / span > < span class = "p" > ;< / span >
2017-05-12 14:19:12 +00:00
< span class = "p" > [< / span > < span class = "n" > self< / span > < span class = "p" > .< / span > < span class = "n" > collectionContext< / span > < span class = "nf" > insertInSectionController< / span > < span class = "p" > :< / span > < span class = "n" > self< / span > < span class = "nf" > atIndexes< / span > < span class = "p" > :[< / span > < span class = "n" > NSIndexSet< / span > < span class = "nf" > indexSetWithIndex< / span > < span class = "p" > :]];< / span >
2018-02-06 23:42:25 +00:00
< span class = "c1" > // NEW< / span >
< span class = "p" > [< / span > < span class = "n" > self< / span > < span class = "p" > .< / span > < span class = "n" > collectionContext< / span > < span class = "nf" > performBatchAnimated< / span > < span class = "p" > :< / span > < span class = "nb" > YES< / span > < span class = "nf" > updates< / span > < span class = "p" > :< / span > < span class = "o" > ^< / span > < span class = "p" > (< / span > < span class = "n" > id< / span > < span class = "o" > < < / span > < span class = "n" > IGListBatchContext< / span > < span class = "o" > > < / span > < span class = "n" > batchContext< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
2017-05-12 14:19:12 +00:00
< span class = "n" > self< / span > < span class = "p" > .< / span > < span class = "n" > expanded< / span > < span class = "o" > =< / span > < span class = "nb" > YES< / span > < span class = "p" > ;< / span >
< span class = "p" > [< / span > < span class = "n" > batchContext< / span > < span class = "nf" > insertInSectionController< / span > < span class = "p" > :< / span > < span class = "n" > self< / span > < span class = "nf" > atIndexes< / span > < span class = "p" > :[< / span > < span class = "n" > NSIndexSet< / span > < span class = "nf" > indexSetWithIndex< / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ]];< / span >
< span class = "p" > }< / span > < span class = "n" > completion< / span > < span class = "o" > :< / span > < span class = "nb" > nil< / span > < span class = "p" > ];< / span >
< / code > < / pre >
< p > < strong > Swift< / strong > < / p >
< pre class = "highlight swift" > < code > < span class = "c1" > // OLD< / span >
< span class = "n" > expanded< / span > < span class = "o" > =< / span > < span class = "kc" > true< / span >
< span class = "n" > collectionContext< / span > < span class = "p" > ?< / span > < span class = "o" > .< / span > < span class = "nf" > insert< / span > < span class = "p" > (< / span > < span class = "nv" > in< / span > < span class = "p" > :< / span > < span class = "k" > self< / span > < span class = "p" > ,< / span > < span class = "nv" > at< / span > < span class = "p" > :< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ])< / span >
< span class = "c1" > // NEW< / span >
< span class = "n" > collectionContext< / span > < span class = "p" > ?< / span > < span class = "o" > .< / span > < span class = "nf" > performBatch< / span > < span class = "p" > (< / span > < span class = "nv" > animated< / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span > < span class = "nv" > updates< / span > < span class = "p" > :< / span > < span class = "p" > {< / span > < span class = "p" > (< / span > < span class = "n" > batchContext< / span > < span class = "p" > )< / span > < span class = "k" > in< / span >
2017-06-01 03:51:02 +00:00
< span class = "k" > self< / span > < span class = "o" > .< / span > < span class = "n" > expanded< / span > < span class = "o" > =< / span > < span class = "kc" > true< / span >
2017-05-12 14:19:12 +00:00
< span class = "n" > batchContext< / span > < span class = "o" > .< / span > < span class = "nf" > insert< / span > < span class = "p" > (< / span > < span class = "nv" > in< / span > < span class = "p" > :< / span > < span class = "k" > self< / span > < span class = "p" > ,< / span > < span class = "nv" > at< / span > < span class = "p" > :< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ])< / span >
< span class = "p" > })< / span >
< / code > < / pre >
2016-11-23 20:42:52 +00:00
2017-05-12 14:19:12 +00:00
< p > Make sure that your model changes occur < strong > inside the update block< / strong > , alongside the context methods.< / p >
< h2 id = 'from-1-x-to-2-x' class = 'heading' > From 1.x to 2.x< / h2 >
2016-11-23 20:42:52 +00:00
2017-05-12 14:19:12 +00:00
< p > For details on all changes in < code > IGListKit< / code > 2.0.0, please see the < a href = "https://github.com/Instagram/IGListKit/releases/tag/2.0.0" > release notes< / a > .< / p >
2018-02-06 23:42:25 +00:00
< h3 id = 'code-iglistdiffable-code-conformance' class = 'heading' > < code > < a href = "Protocols/IGListDiffable.html" > IGListDiffable< / a > < / code > Conformance< / h3 >
2016-12-02 14:47:23 +00:00
2018-02-06 23:42:25 +00:00
< p > If you relied on the default < code > NSObject< IGListDiffable> < / code > category, you will need to add < code > < a href = "Protocols/IGListDiffable.html" > IGListDiffable< / a > < / code > conformance to each of your models. To get things working as they did in 1.0, simply add the following to each of your models:< / p >
2016-12-02 14:47:23 +00:00
2016-12-04 19:15:58 +00:00
< p > < strong > Objective-C< / strong > < / p >
< pre class = "highlight objective_c" > < code > < span class = "cp" > #import < IGListKit/IGListDiffable.h>
< / span >
2018-02-06 23:42:25 +00:00
< span class = "c1" > // Header< / span >
< span class = "k" > @interface< / span > < span class = "nc" > MyModel< / span > < span class = "o" > < < / span > < span class = "n" > IGListDiffable< / span > < span class = "o" > > < / span >
2016-12-02 14:47:23 +00:00
2018-02-06 23:42:25 +00:00
< span class = "c1" > // Implementation< / span >
< span class = "o" > -< / span > < span class = "p" > (< / span > < span class = "n" > id< / span > < span class = "o" > < < / span > < span class = "n" > NSObject< / span > < span class = "o" > > < / span > < span class = "p" > )< / span > < span class = "n" > diffIdentifier< / span > < span class = "p" > {< / span >
2016-12-04 19:15:58 +00:00
< span class = "k" > return< / span > < span class = "n" > self< / span > < span class = "p" > ;< / span >
< span class = "p" > }< / span >
2016-12-02 14:47:23 +00:00
2016-12-04 19:15:58 +00:00
< span class = "o" > -< / span > < span class = "p" > (< / span > < span class = "n" > BOOL< / span > < span class = "p" > )< / span > < span class = "n" > isEqualToDiffableObject< / span > < span class = "o" > :< / span > < span class = "p" > (< / span > < span class = "n" > id< / span > < span class = "o" > < < / span > < span class = "n" > IGListDiffable< / span > < span class = "o" > > < / span > < span class = "p" > )< / span > < span class = "n" > object< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "p" > [< / span > < span class = "n" > self< / span > < span class = "nf" > isEqual< / span > < span class = "p" > :< / span > < span class = "n" > object< / span > < span class = "p" > ];< / span >
< span class = "p" > }< / span >
< / code > < / pre >
2016-12-02 14:47:23 +00:00
2016-12-04 19:15:58 +00:00
< p > < strong > Swift< / strong > < / p >
< pre class = "highlight swift" > < code > < span class = "kd" > import< / span > < span class = "kt" > IGListKit< / span >
2016-12-02 14:47:23 +00:00
2017-05-12 14:19:12 +00:00
< span class = "kd" > extension< / span > < span class = "kt" > MyModel< / span > < span class = "p" > :< / span > < span class = "kt" > ListDiffable< / span > < span class = "p" > {< / span >
2016-12-04 19:15:58 +00:00
< span class = "kd" > func< / span > < span class = "nf" > diffIdentifier< / span > < span class = "p" > ()< / span > < span class = "o" > -> < / span > < span class = "kt" > NSObjectProtocol< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "k" > self< / span >
< span class = "p" > }< / span >
2016-12-02 14:47:23 +00:00
2017-05-12 14:19:12 +00:00
< span class = "kd" > func< / span > < span class = "nf" > isEqual< / span > < span class = "p" > (< / span > < span class = "n" > toDiffableObject< / span > < span class = "nv" > object< / span > < span class = "p" > :< / span > < span class = "kt" > ListDiffable< / span > < span class = "p" > ?)< / span > < span class = "o" > -> < / span > < span class = "kt" > Bool< / span > < span class = "p" > {< / span >
2016-12-04 19:15:58 +00:00
< span class = "k" > return< / span > < span class = "nf" > isEqual< / span > < span class = "p" > (< / span > < span class = "n" > object< / span > < span class = "p" > )< / span >
< span class = "p" > }< / span >
< span class = "p" > }< / span >
< / code > < / pre >
2016-12-02 14:47:23 +00:00
< p > However we recommend writing more thorough identity and equality checks. Check out our guide to < a href = "https://instagram.github.io/IGListKit/iglistdiffable-and-equality.html" > IGListDiffable and Equality< / a > for more info.< / p >
2016-11-23 20:42:52 +00:00
< / section >
< / section >
< section id = "footer" >
2018-05-01 23:54:35 +00:00
< p > © 2018 < a class = "link" href = "https://twitter.com/fbOpenSource" target = "_blank" rel = "external" > Instagram< / a > . All rights reserved. (Last updated: 2018-05-01)< / p >
2018-02-06 23:42:25 +00:00
< p > Generated by < a class = "link" href = "https://github.com/realm/jazzy" target = "_blank" rel = "external" > jazzy ♪♫ v0.9.1< / a > , a < a class = "link" href = "http://realm.io" target = "_blank" rel = "external" > Realm< / a > project.< / p >
2016-11-23 20:42:52 +00:00
< / section >
< / article >
< / div >
< / body >
< / div >
< / html >