Skip to content

Instantly share code, notes, and snippets.

View NikKovIos's full-sized avatar
💭
Ready to work!) Zog zog

NikeKov NikKovIos

💭
Ready to work!) Zog zog
View GitHub Profile
@NikKovIos
NikKovIos / RealmIndexOutOfBoundsFix.swift
Last active February 10, 2018 08:23
Realm prevent crash for `Index x is out of bounds (must be less than x)`
// 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]