String
public extension String
-
Returns
nil
if string is emptyDeclaration
Swift
var nilIfEmpty: String? { get }
-
Truncates a given string after the given
length
based on the rule set by theposition
.If the string in
self
is shorter than the givenlength
, it won’t be truncatedDeclaration
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