Skip to content

Instantly share code, notes, and snippets.

@ncreated
Created November 22, 2016 12:55
Show Gist options
  • Save ncreated/f124a1770901abea98e6ecc0f97afb0f to your computer and use it in GitHub Desktop.
Save ncreated/f124a1770901abea98e6ecc0f97afb0f to your computer and use it in GitHub Desktop.
// Crash:
let cell = tableView.dequeueReusableCell(withIdentifier: Constants.twoLabelsCellIdentifier) as! TwoLabelsIconCell
// Crash with verbose message:
guard let cell = tableView.dequeueReusableCell(withIdentifier: Constants.twoLabelsCellIdentifier) as? TwoLabelsIconCell else {
fatalEror("Cannot dequeue `TwoLabelsIconCell`")
}
// Crash in DEBUG, recover in Release:
guard let cell = tableView.dequeueReusableCell(withIdentifier: Constants.twoLabelsCellIdentifier) as? TwoLabelsIconCell else {
assertionFailure("Cannot dequeue `TwoLabelsIconCell`")
return TwoLabelsIconCell()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment