title: How to URL encode a NSString
body: <p>I am trying to url encode a string, but the NSURLConnection is failing because of a 'bad url'. Here is my URL:</p>
  
  <pre><code>    NSString *address = mp.streetAddress;
      NSString *encodedAddress = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
      NSString *cityState= mp.cityState;
      NSString *encodedCityState = [cityState stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  
      NSString *fullAddressURL = [NSString stringWithFormat:@"http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=&lt;X1-ZWz1bivd5de5mz_8xo7s&gt;&amp;address=%@&amp;citystatezip=%@", encodedAddress, encodedCityState];
      NSURL *url = [NSURL URLWithString:fullAddressURL];
  </code></pre>
  
  <p>Here is the API's example of calling the URL:</p>
  
  <p>Below is an example of calling the API for the address for the exact address match "2114 Bigelow Ave", "Seattle, WA":</p>
  
  <pre><code>http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=&lt;ZWSID&gt;&amp;address=2114+Bigelow+Ave&amp;citystatezip=Seattle%2C+WA
  </code></pre>
  
  <p>For some reason this URL is failing to connect. Can someone help me out?</p>