Skip to content

Commit

Permalink
Update Best Practices and FAQ.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Feb 13, 2017
1 parent 8516fa7 commit 148c02e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Guides/Best Practices and FAQ.md
Expand Up @@ -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.
Expand Down

0 comments on commit 148c02e

Please sign in to comment.