---
title: "componentsJoined(by:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/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.

## Declaration

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

## Parameters

- `separator`: The string to interpose between the elements of the array.

## Return Value

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

Discussion For example, this code excerpt writes “here be dragons” to the console: NSArray *pathArray = [NSArray arrayWithObjects:@"here", @"be", @"dragons", nil]; NSLog(@"%@",[pathArray componentsJoinedByString:@" "]); Special Considerations Each element in the array must handle description.

## See Also

### Related Documentation

- [components(separatedBy:)](foundation/nsstring/components(separatedby:)-238fy.md)
