Instance Method

appending(_:)

Returns a new string made by appending a given string to the receiver.

Declaration

func appending(_ aString: String) -> String

Parameters

aString

The string to append to the receiver. This value must not be nil.

Return Value

A new string made by appending aString to the receiver.

Discussion

This code excerpt, for example:

NSString *errorTag = @"Error: ";
NSString *errorString = @"premature end of file.";
NSString *errorMessage = [errorTag stringByAppendingString:errorString];

produces the string “Error: premature end of file.”.

See Also

Combining Strings

func padding(toLength: Int, withPad: String, startingAt: Int)

Returns a new string formed from the receiver by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string.