john doe john doe - 1 month ago 7
Swift Question

Conditional Binding for Optionals

I have the following code and it complains about the as! keyword. If I replace with as? it works fine.

enter image description here

Answer

You can't do force unwrapping in guard or if let. Use optionals. The end product which is name in your case is already an unwrapped value for you.

Replace as! with as?

Comments