我想获取相对路径,但我在下面的代码中获取了完整路径。 Xcode 14.3
let homePath = NSHomeDirectory()
let homeURL = URL(fileURLWithPath: ".", relativeTo: URL(fileURLWithPath: homePath))
guard let fileEnumeratorIncludingSubFolder = FileManager.default.enumerator(
at: homeURL,
includingPropertiesForKeys: [],
options: [.skipsHiddenFiles, .skipsPackageDescendants])
else { fatalError() }
for case let fileURL as URL in fileEnumeratorIncludingSubFolder {
print(fileURL.relativePath) // Expected relative path but full path
}