title: Objective - C stringByAddingPercentEncodingWithAllowedCharacters not working
body: <p>I have a URL like so ANC &amp; SHO.pdf</p>
  
  <p>when I encode the URL like so:</p>
  
  <pre><code>NSString *escapedString = [PDFPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
  </code></pre>
  
  <p>now when I use this URL it does not work and I have a feeling it has to do with the &amp; because when I tried another file, it worked perfectly I was able to load the PDF, but with the file with &amp; I was not.</p>
  
  <p>What Am I doing wrong?</p>
  
  <p>Here is the output of escapedString </p>
  
  <pre><code>escapedString   __NSCFString *  @"Ancaster%5CANC%20&amp;%20SHO%20-%20Laundry%20Closets%20to%20be%20Checked.pdf" 0x16ea33c0
  </code></pre>
  
  <p>I then use that to call a method:</p>
  
  <pre><code>NSArray *byteArray = [dataSource.areaData GetPDFFileData:[NSString stringWithFormat:@"%@",escapedString]];
  </code></pre>
  
  <p>Here is the method:</p>
  
  <pre><code>-(NSArray *)GetPDFFileData:(NSString *)PDFFile
  {
      NSString *FileBrowserRequestString = [NSString stringWithFormat:@"%@?PDFFile=%@",kIP,PDFFile];
      NSURL *JSONURL = [NSURL URLWithString:FileBrowserRequestString];
      NSURLResponse* response = nil;
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:JSONURL];
      NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:nil];
      if(data == nil)
          return nil;
      NSError *myError;
      NSArray *tableArray = [[NSArray alloc]initWithArray:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;myError]];
      return tableArray;
  }
  </code></pre>