Handling empty optional strings in Swift
Nathan Chan
68017

Correct me if I’m wrong but isn’t there a rogue ‘else’ in here on the first line?

if let title = textField.text else {
if title.isEmpty {
// Alert: textField is empty!
}
// title String is now unwrapped, non-empty, and ready for use
}
Like what you read? Give Mike Rolls a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.