<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/appending(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)stringByAppendingString:"
  },
  "title" : "appending(_:)"
}
-->

# appending(_:)

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

```
func appending(_ aString: String) -> String
```

## Parameters

`aString`

The string to append to the receiver. This value must not be `nil`.
  
  > Important:
  > Raises an `NSInvalidArgumentException` if `aString` is `nil`.

## Return Value

A new string made by appending `aString` to the receiver.

## Discussion

This code excerpt, for example:

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

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

## See Also

[`-  stringByAppendingFormat:`](/documentation/Foundation/NSString/stringByAppendingFormat:)

Returns a string made by appending to the receiver a string constructed from a given format string and the following arguments.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)