iphone - stringWithContentsOfURL not working with certain string -


I have the same code as a URL like the following ... If I use the URL for the first time, the webpage Will come back to zero. If I put this URL into a bit like a URL shorting system, then it works and gives the page HTML as a string. I can only think that my first * url contains invalid characters? any idea?

  NSString * url = @ "http://www.testurl.com/testing/testapp.aspx/app.detail/params.frames.y.tpl.uk.item.1. Cm_scid.TB Exam / left.html | metadrill, html / walk.yah.ukHB cm_re = LN -_- OnNow -_- TestOne ".? // The above * url does not work, below is an NSURL * url = [NSURL URLWithString: @ "http://bit.ly/shortened"]; NSString * webpage = [NSString stringWithContentsOfURL: url]; You must save some characters in some URLs, as follows:  

NSString * url = @ "http://www.testurl.com/testing/testapp.aspx/app.detail/params.frames.y.tpl.uk.item.1.cm_scid. .? TB test / left.html | metadrill, html / walk.yah.ukHB cm_re = LN -_- OnNow -_- TestOne "; NSString * escapedURL = [URL stringbazing on multicasketing encoding: NASCIITTN encoding]; NSString * webpage = [NSString stringWithContentsOfURL: [NSURL URLWithString: escapedURL]];

The URL will be created and its worth failing if the URL contains characters that are not properly saved on your URL, it may be a pipe (|), question mark, or underscore ).


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -