title: iOS Develoment: Why is my NSURLConnection failing with a "bad URL" error for only some users?
body: <p>I have an iOS app that requests <code>JSON</code> data from my Rails 3 app, hosted on Heroku, and it works great on my device and for many other users, except one.  I have one user who has told me that my app fails to retrieve the JSON data, so I had her send me some log data and the log showed the <code>NSURLConnection</code> delegate method <code>didFailWithError</code> is being called and the error description reads <strong>"bad URL"</strong>.  Why is this error occurring and why is it ONLY occurring on just some devices instead of all devices?</p>
  
  <p>Here's my code, </p>
  
  <pre><code>-(void)getTournamentInfoWithUsername:(NSString*)username
  {
      NSString *urlString = [NSString stringWithFormat:@"http://myapp-tourney.heroku.com/tournaments/next.json?username=%@", username];
      NSURL *url = [NSURL URLWithString:urlString];
      NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
      [self setUrlConnection:[[NSURLConnection alloc] initWithRequest:request delegate:self]];
  }
  
  - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
  {
      [MyLog logError:[NSString stringWithFormat:@"%@ - %@ - %@ - %@", [error localizedDescription], [error localizedFailureReason], [error localizedRecoveryOptions], [error localizedRecoverySuggestion]]];
  }
  </code></pre>
  
  <p>and the log shows...</p>
  
  <pre><code>bad URL - (null) - (null) - (null)
  </code></pre>
  
  <p>Thanks so much for all your wisdom!</p>