You should really do away with legacy `NS` Objective-C classes and manual path string splitting where possible. Use `URL` instead:
let url = URL(fileURLWithPath: "a/b/c.dat", isDirectory: false)
let path = url.deletingLastPathComponent().relativePath // 'a/b'
let file = url.lastPathComponent // 'c.dat'
That being said, Apple has an explicit [FilePath](
[To see links please register here]
) type starting with macOS 11, but with no path manipulation methods. For those you'd have to include the external [system package](
[To see links please register here]
)
If you are on macOS 12, the methods from the external package are now also available on the system.