Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Crash report 💥] Replace Optional Cell Handling with Unwrapped Implementation. #1381

Open
gokulvenkat243 opened this issue Dec 17, 2024 · 0 comments

Comments

@gokulvenkat243
Copy link
Contributor

gokulvenkat243 commented Dec 17, 2024

Current Code:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell"r, for: indexPath) as! TableviewCell

  • Here using as!. but it’s risky.

Why Avoid?

  • If the cell is fails, the app will be crashed
  • Suitable only when you are 100% confident the cell type is correct

Instead of:
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? TableviewCell else
{
fatalError("Wrong cell")
}

  • This is the safest and most common way to unwrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant