StringProtocol

public extension StringProtocol
  • Returns string as URL. Properly escapes URL components if needed.

    Declaration

    Swift

    var asURL: URL? { get }
  • Returns self as file URL

    Declaration

    Swift

    var asFileURL: URL { get }
  • Returns self as Int

    Declaration

    Swift

    var asInt: Int? { get }
  • Returns self as Double

    Declaration

    Swift

    var asDouble: Double? { get }
  • Returns self as String

    Declaration

    Swift

    var asString: String { get }
  • Returns string as NSAttributedString

    Declaration

    Swift

    var asAttributedString: NSAttributedString { get }
  • Returns string as NSMutableAttributedString

    Declaration

    Swift

    var asMutableAttributedString: NSMutableAttributedString { get }

Base64

  • Returns base64 encoded string

    Declaration

    Swift

    var encodedBase64: String? { get }
  • Returns string decoded from base64 string

    Declaration

    Swift

    var decodedBase64: String? { get }

Trimming

  • Strips whitespace and new line characters

    Declaration

    Swift

    var trimmed: String { get }

Splitting

  • Splits string by capital letters without stripping them

    Declaration

    Swift

    var splittedByCapitals: [String] { get }
  • Split string into slices of specified length

    Declaration

    Swift

    func splitByLength(_ length: Int) -> [String]

Bounding Rect

  • Width of a string written in one line.

    Declaration

    Swift

    func oneLineWidth(font: UIFont) -> CGFloat
  • Height of a string for specified font and width.

    Declaration

    Swift

    func height(font: UIFont, width: CGFloat) -> CGFloat
  • Height of a string for specified attributes and width.

    Declaration

    Swift

    func height(attributes: [NSAttributedString.Key : Any], width: CGFloat) -> CGFloat

Capitalization

Subscript

  • Undocumented

    Declaration

    Swift

    subscript(value: Int) -> Character { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: NSRange) -> SubSequence { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: CountableClosedRange<Int>) -> SubSequence { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: CountableRange<Int>) -> SubSequence { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: PartialRangeUpTo<Int>) -> SubSequence { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: PartialRangeThrough<Int>) -> SubSequence { get }
  • Undocumented

    Declaration

    Swift

    subscript(value: PartialRangeFrom<Int>) -> SubSequence { get }