CFURLCopyLastPathComponent(_:)
Returns the last path component of a given URL.
Declaration
func CFURLCopyLastPathComponent(_ url: CFURL!) -> CFString!Parameters
- url:
The
CFURLobject to examine.
Return Value
The last path component of url. Ownership follows the create rule. See The Create Rule.
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(_:)CFURLCopyFileSystemPath(_:_:)CFURLCopyFragment(_:_:)CFURLCopyHostName(_:)CFURLCopyNetLocation(_:)CFURLCopyParameterString(_:_:)CFURLCopyPassword(_:)CFURLCopyPath(_:)CFURLCopyPathExtension(_:)CFURLCopyQueryString(_:_:)CFURLCopyResourceSpecifier(_:)CFURLCopyScheme(_:)CFURLCopyStrictPath(_:_:)CFURLCopyUserName(_:)CFURLGetPortNumber(_:)