public extension Optional where Wrapped == String

Extension for optional String.

  • This method is an adaptation of isEmpty() method for the Optional String. Note that it ignores the whitespace content when checking for emptiness. For example, \t.hasContent is false. For a nil String, hasContent returns false, too.



    var hasContent: Bool { get }

    Return Value

    True if the string is neither nil nor empty and false otherwise.