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 aNSString
.Equivalent to using
(String(self) as NSString).length
orself.utf16.count
Declaration
Swift
public var nsLength: Int { 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
isfalse
, andnil
if it istrue
Declaration
Swift
public var nonEmptyValue: Self? { get }
-
Returns the receiver if
isBlank
isfalse
, andnil
if it istrue
Declaration
Swift
public var nonBlankValue: Self? { get }