Note that there are some explanatory texts on larger screens.

plurals
  1. PONSUTF8StringEncoding gives me this %0A%20%20%20%20%22http://example.com/example.jpg%22%0A
    text
    copied!<p>I'm trying to load pictures from twitter. If i just use the URL in the json results without encoding, in the <code>dataWithContentsOfURL</code>, I get nil URL argument. If I encode it, I get as follow's</p> <blockquote> <p>%0A%20%20%20%20%22http://example.com/example.jpg%22%0A.</p> </blockquote> <p>I know I can use <code>rangeOfString:</code> or <code>stringByReplacingOccurrencesOfString:</code> but can I be sure that it will always be the same, is there another way to handle this, and why is this happening to my twitter response and not my instagram response?</p> <p>I have also tried</p> <pre><code>stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet] </code></pre> <p>and it does nothing.</p> <p>This is the URL directly from the json...</p> <pre><code>2013-11-08 22:09:31:812 JaVu[1839:1547] -[SingleEventTableViewController tableView:cellForRowAtIndexPath:] [Line 406] ( "http://pbs.twimg.com/media/BYWHiq1IYAAwSCR.jpg" ) </code></pre> <p>Here is my code</p> <pre><code>if ([post valueForKeyPath:@"entities.media.media_url"]) { NSString *twitterString = [[NSString stringWithFormat:@"%@", [post valueForKeyPath:@"entities.media.media_url"]]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; twitterString = [twitterString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"%@", twitterString); if (twitterString != nil){ NSURL *twitterPhotoUrl = [NSURL URLWithString:twitterString]; NSLog(@"%@", twitterPhotoUrl); dispatch_queue_t queue = kBgQueue; dispatch_async(queue, ^{ NSError *error; NSData* data = [NSData dataWithContentsOfURL:twitterPhotoUrl options:NSDataReadingUncached error:&amp;error]; UIImage *image = [UIImage imageWithData:data]; dispatch_sync(dispatch_get_main_queue(), ^{ [streamPhotoArray replaceObjectAtIndex:indexPath.row withObject:image]; cell.instagramPhoto.image = image; }); }); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload