ne of our views that contains a UICollectionView started crashing once in a while...

The problem:

One of our views that contains a UICollectionView started crashing once in a while with the following descriptive error:

libc++abi.dylib: terminating with uncaught exception of type NSException

Stack trace was not very helpful.

The solution:

Most of the uncaught exception in a collection view occur when it is being partially reloaded (insertItems, reloadItems, reloadSections, etc.) and its data-source is not what it expects to be.

In our case, we re-used the same collection view and did not run self.collectionView.reloadData() before each re-use so adding that line of code fixed the issue.

Welcome to The infinite monkey theorem

Somewhere a monkey just typed Shakespeare in TypeScript. Be the first to read the masterpieces (and the hilarious misfires) landing on the blog.

Subscribe to The infinite monkey theorem

We fling fresh posts—no banana peels attached—straight to your inbox.