Playing with URLs, more specifically building them incrementally from other, discovered URLs. In doing so, I'd like to stay using NSURL objects instead of manipulating NSStrings, just to gain the added sanity checks and url-specific methods from the URL class.
Unfortunately, it seems that there is no way to get the following to join together how I wish:
NSURL *base = [NSURL URLWithString:@"http://my.url/path"]; NSString *suffix = @"sub/path";
I want to append them to get:
http://my.url/path/sub/path
But the best I can seem to get is:
NSURL *final = [NSURL URLWithString:suffix relativeToURL:base];
Which trims off the path on the base, resulting in:
http://my.url/sub/path
There's a CoreFoundation function that does it:
CFURLRef CFURLCreateCopyAppendingPathComponent ( CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory );
Which seems to work fine, but bouncing back/forth from ObjC to C is jarring and annoying... I'd rather just manipulate strings... Am I missing something? Other than being way too picky of course. :)