<!--
{
  "availability" : [
    "iOS: 8.0.0 - 27.0.0",
    "iPadOS: 8.0.0 - 27.0.0",
    "macCatalyst: 8.0.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 2.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/appendPathComponent(_:isDirectory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV19appendPathComponent_11isDirectoryySS_SbtF"
  },
  "title" : "appendPathComponent(_:isDirectory:)"
}
-->

# appendPathComponent(_:isDirectory:)

Appends a path component to the URL, specifying whether the resulting path is a directory.

```
mutating func appendPathComponent(_ pathComponent: String, isDirectory: Bool)
```

## Parameters

`pathComponent`

The path component to add.

`isDirectory`

Use `true` if the resulting path is a directory.

## Discussion

New code should use [`append(path:directoryHint:)`](/documentation/Foundation/URL/append(path:directoryHint:)) instead of this method.

---

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)