Guest User

Untitled

a guest
Dec 11th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. extension Optional where Wrapped == String {
  2. var nilIfEmpty: String? {
  3. guard let strongSelf = self else {
  4. return nil
  5. }
  6. return strongSelf.isEmpty ? nil : strongSelf
  7. }
  8. }
  9.  
  10. guard let title = textField.text.nilIfEmpty else {
  11. // Alert: textField is empty!
  12. return
  13. }
  14. // title String is now unwrapped, non-empty, and ready for use
Add Comment
Please, Sign In to add comment