Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +(void)baseUrls {
  2.  
  3.     NSArray *requestURLs = @[@"/api/v3.1/User​/Page/",
  4.                              @"api/v3.1/User​/Page",
  5.                              @"/api/v3.1/User​/Page/",
  6.                              @"/api/v3.1/Follow/Page",
  7.                              @"/api/v3.1/User/Follow",
  8.                              @"/api/v3.1/User/Page",
  9.                              @"api/v3.2/User​/Page",
  10.                              @"api/v3.2/User​/Page/aaa/bbb"];
  11.  
  12.  
  13.     NSURL *baseURL = [NSURL URLWithString:@"http://appgateway.xxx.xx-xxx.xxx.com/"];
  14.  
  15.     for (NSString *aRequestURL in requestURLs) {
  16.         NSURL *constructedURL = [NSURL URLWithString:aRequestURL relativeToURL:baseURL];
  17.         if (constructedURL) {
  18.             NSLog(@"Success: %@", constructedURL.absoluteString);
  19.         } else {
  20.             NSLog(@"Error  : %@ + %@", baseURL.absoluteString, aRequestURL);
  21.         }
  22.     }
  23.     //WORKS
  24.     NSURL *hardCoded = [NSURL URLWithString:@"/api/v3.1/Follow/Page" relativeToURL:baseURL];
  25.     NSLog(@"HardCoded: %@", hardCoded.absoluteString);
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement