StringProtocol

protocol StringProtocol : BidirectionalCollection, Comparable, ExpressibleByStringLiteral, Hashable, LosslessStringConvertible, TextOutputStream, TextOutputStreamable where Self.Element == Character, Self.SubSequence : StringProtocol
  • Returns the equivalent length of the string (as given by NSString.length) if the receiver’s content was in a NSString.

    Equivalent to using (String(self) as NSString).length or self.utf16.count

    Declaration

    Swift

    public var nsLength: Int { get }
  • Deprecated: Please use nsRange instead.

    Refer to the documentation for nsRange for more info.

    Declaration

    Swift

    @available(*, deprecated, renamed: "nsRange")
    public var fullRange: NSRange { get }
  • Returns NSRange(location: 0, length: nsLength) for usage with Objective-C APIs.

    Declaration

    Swift

    public var nsRange: NSRange { get }
  • Returns a URL percent-encoded as per RFC 3986 section 2.3 Unreserved Characters (January 2005)

    Declaration

    Swift

    public func urlSafeString() -> String
  • Returns true if the receiver is empty or if it only contains whitespaces or newlines

    Declaration

    Swift

    public var isBlank: Bool { get }
  • Returns the receiver if isEmpty is false, and nil if it is true

    Declaration

    Swift

    public var nonEmptyValue: Self? { get }
  • Returns the receiver if isBlank is false, and nil if it is true

    Declaration

    Swift

    public var nonBlankValue: Self? { get }