I have a table view linked to a NSFetchedResultController
(i.e. loading data and also tracking changes to data is bound to the FRC)
I\'m not using Auto
If anyone encountered the same problem:
If you are calculating your cell height and its elements and you are dependent on NSIndexPath
for querying any data or conditions, always check that your index path is valid (not nil
). Most of UITableView
methods that return index path (e.g -(NSIndexPath *)indexPathForCell:..
, etc.) may return nil
values and will shoot you down an spiral that is debugging views.
In my case, I had a method to determined if my cell should have a header, and for that I checked wether it is the first cell or a condition has changed since previous cell. the problem was indexPath.row == 0
is true even if the index path is actually nil
(it's a conceptual problem in Objective-C where nil
is 0). so for a brief moment my cells would thought it has a header!
I feel kind of stupid not checking for nil
index paths but I think sharing it might help somebody someday.