Last active
February 10, 2018 08:23
-
-
Save NikKovIos/78fc01e7230c8081706802a5f9f8f364 to your computer and use it in GitHub Desktop.
Realm prevent crash for `Index x is out of bounds (must be less than x)`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use | |
if indexPath.row < arrayOfObjects.count { | |
cell.label.text = arrayOfObjects[indexPath.row] | |
} else { | |
// Handle non-existing object here | |
} | |
// Example: | |
if let wheel = wheel, let row = indexPath?.row, row < wheel.comments.count { | |
let comment = wheel.comments[row] | |
nameLabel.text = comment.userName | |
bodyLabel.text = comment.text | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment