@DTS Engineer
Thank you for your detailed response and for adding comments to my bug report.
I have a few follow-up questions:
Thanks. I’ve added my own comments to your bug.
I tried to access FB21757864 via Feedback Assistant, but I don't see any replies yet. Are internal comments visible to the reporter, or are they only accessible to Apple engineers?
Ah, I’ve found myself in that very conundrum. It’s annoying that we never got a Swift equivalent of Objective-C’s -stringByDeletingPathExtension method. I think it’d be reasonable for you to file an enhancement request for that. And if you do, please post that bug number as well.
I found deletingpathextension in Swift. Is this the method you were referring to ?
Regardless, given your requirements I agree that prepending a slash is a reasonable option.
You mentioned that prepending a slash is a reasonable option. However, since our use case involves pure string manipulation (extracting filename and extension from a
server-provided filename string), would using NSString methods be the more semantically correct approach? For example:
let fileName = ((fileNameWithExtension as NSString).deletingPathExtension as NSString).lastPathComponent
let fileExtension = (fileNameWithExtension as NSString).pathExtension
This avoids URL semantics entirely and treats the input as what it actually is—a filename string rather than a path.
I'd appreciate your guidance on whether this approach is recommended over the URL-based solution.