From 148c02e7adfce5ba934b182cffea630cc63fea34 Mon Sep 17 00:00:00 2001 From: Jesse Squires Date: Mon, 13 Feb 2017 10:50:27 -0800 Subject: [PATCH] Update Best Practices and FAQ.md --- Guides/Best Practices and FAQ.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Guides/Best Practices and FAQ.md b/Guides/Best Practices and FAQ.md index fdf9eefdb..c0e9db3ca 100644 --- a/Guides/Best Practices and FAQ.md +++ b/Guides/Best Practices and FAQ.md @@ -10,12 +10,21 @@ If this assert is ever hit, that means `IGListKit` has sent your section control This would only happen if your objects provide *non-unique* diff identifiers. ```objective-c +// Objective-C - (void)didUpdateToObject:(id)object { NSParameterAssert([object isKindOfClass:[MyModelClass class]]); _myModel = object; } ``` +```swift +// Swift +func didUpdate(to object: Any) { + precondition(object is MyModelClass) + myModel = object as! MyModelClass +} +``` + - Make sure your [`-diffIdentifier`](https://instagram.github.io/IGListKit/Protocols/IGListDiffable.html#/c:objc(pl)IGListDiffable(im)diffIdentifier) implementation returns a **unique identifier** for each object. - We highly recommend using single-item sections when possible. That is, each section controller manages a single model (which may have one or multiple cells). This gives you the greatest amount of flexibility, modularity, and re-use for your components.