Saturday, July 13, 2013

URL Path Retrieval Cheat Sheet

Mike Abdullah:

As Cocoa developers, there’s quite a broad range of APIs available to us for pulling out the path component of a URL. I often forget the particular quirks of them, so here’s a handy cheat sheet to bring all that together.

Without reading the documentation, you might have assumed that CFURLCopyPath() and -[NSURL path] were equivalent.

4 Comments RSS · Twitter

The table could be improved from a legibility point of view.

All of them treat URL paths as strings, which is problematic when the path character encoding is unknown.

@Jim Are you saying it’s a problem that -[NSURL path] assumes Unicode when decoding the percent escapes? Or are you referring to something else?

Leave a Comment