String

public extension String
  • Returns nil if string is empty

    Declaration

    Swift

    var nilIfEmpty: String? { get }
  • Truncates a given string after the given length based on the rule set by the position.

    If the string in self is shorter than the given length, it won’t be truncated

    Declaration

    Swift

    public func truncated(to length: Int, at position: TruncatingPosition = .lead) -> String

    Parameters

    length

    Length of result string

    position

    Defines where to truncate the string, see TruncatingPosition

    Return Value

    Truncated version of self