---
title: "CFURLCopyLastPathComponent(_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfurlcopylastpathcomponent(_:)"
---

# CFURLCopyLastPathComponent(_:)

Returns the last path component of a given URL.

## Declaration

```swift
func CFURLCopyLastPathComponent(_ url: CFURL!) -> CFString!
```

## Parameters

- `url`: The CFURL object to examine.

## Return Value

Return Value The last path component of url. Ownership follows the create rule. See The Create Rule.

## Discussion

Discussion Note that if there is no last path component, this function returns an empty string. In the code sample shown, lastPathComponent is an empty string. CFStringRef urlString = CFSTR("http://www.apple.com"); CFURLRef url = CFURLCreateWithString(NULL, urlString, NULL); CFStringRef lastPathComponent = CFURLCopyLastPathComponent (url); If urlString were created with CFSTR("http://www.apple.com/"), then lastPathComponent would be a CFString object containing the character “/”. See also CFURLCopyPathExtension(_:).

## See Also

### Accessing the Parts of a URL

- [CFURLCanBeDecomposed(_:)](corefoundation/cfurlcanbedecomposed(_:).md)
- [CFURLCopyFileSystemPath(_:_:)](corefoundation/cfurlcopyfilesystempath(_:_:).md)
- [CFURLCopyFragment(_:_:)](corefoundation/cfurlcopyfragment(_:_:).md)
- [CFURLCopyHostName(_:)](corefoundation/cfurlcopyhostname(_:).md)
- [CFURLCopyNetLocation(_:)](corefoundation/cfurlcopynetlocation(_:).md)
- [CFURLCopyParameterString(_:_:)](corefoundation/cfurlcopyparameterstring(_:_:).md)
- [CFURLCopyPassword(_:)](corefoundation/cfurlcopypassword(_:).md)
- [CFURLCopyPath(_:)](corefoundation/cfurlcopypath(_:).md)
- [CFURLCopyPathExtension(_:)](corefoundation/cfurlcopypathextension(_:).md)
- [CFURLCopyQueryString(_:_:)](corefoundation/cfurlcopyquerystring(_:_:).md)
- [CFURLCopyResourceSpecifier(_:)](corefoundation/cfurlcopyresourcespecifier(_:).md)
- [CFURLCopyScheme(_:)](corefoundation/cfurlcopyscheme(_:).md)
- [CFURLCopyStrictPath(_:_:)](corefoundation/cfurlcopystrictpath(_:_:).md)
- [CFURLCopyUserName(_:)](corefoundation/cfurlcopyusername(_:).md)
- [CFURLGetPortNumber(_:)](corefoundation/cfurlgetportnumber(_:).md)
