<!--
{
  "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/NSArray/componentsJoined(by:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)componentsJoinedByString:"
  },
  "title" : "componentsJoined(by:)"
}
-->

# componentsJoined(by:)

Constructs and returns an `NSString` object that is the result of interposing a given separator between the elements of the array.

```
func componentsJoined(by separator: String) -> String
```

## Parameters

`separator`

The string to interpose between the elements of the array.

## Return Value

An `NSString` object that is the result of interposing `separator` between the elements of the array. If the array has no elements, returns an `NSString` object representing an empty string.

## Discussion

For example, this code excerpt writes “`here be dragons`” to the console:

```objc
NSArray *pathArray = [NSArray arrayWithObjects:@"here", @"be", @"dragons", nil];
NSLog(@"%@",[pathArray componentsJoinedByString:@" "]);
```

### Special Considerations

Each element in the array must handle `description`.

## See Also

[`-  componentsSeparatedByString:`](/documentation/Foundation/NSString/components(separatedBy:)-238fy)

Returns an array containing substrings from the receiver that have been divided by a given separator.



---

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)