Nat! bio photo

Nat!

Senior Mull.

Twitter RSS

Github

hairloss, due to NSURL

Another beauty. Here's the code and the output:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
   NSURL   *url;
   
   @autoreleasepool
   {
      url = [NSURL URLWithString:@"/de/index.html"];
      NSLog( @"%@", url);

      url = [NSURL URLWithString:@"/de"];
      url = [NSURL URLWithString:@"index.html"
                   relativeToURL:url];
      NSLog( @"%@", url);
   }
   return 0;
}

prints

2014-01-15 23:02:21.341 NSURLRelative[8974:303] /de/index.html
2014-01-15 23:02:21.342 NSURLRelative[8974:303] index.html -- /de

Now the second URL looks obviously corrupted. I couldn't figure out how to use +[NSURL URLWithString:relativeToURL] with any combinations of input. But ZNeK did. Solution in rot13 :)

Gur HEY vf npghnyyl BX whfg gur <gg>-qrfpevcgvba</gg> vf aba-frafvpny.