14 October 2007

stringWithContentsOfURL:encoding:error: throws NSDocumentedByMorons

If there's one thing I am intolerant of, it's ignorance. Especially in professionals. If you're paid to do something, then you had better well be able to do it! The great Paula, er, sorry, the *brillant* Paula, for example would get NO sympathy or appreciation from me.

So what then would I do about the folks responsible for the documentation for Foundation Framework's NSString class, in particular the masterpiece for stringWithContentsOfURL.

Take a good read of that documentation. It's the best you'll find for the function. Any reason then to think the following would NOT work?

NSURL * url = [NSURL URLWithString:@"http://www.google.com/"];
NSString * webpage = [NSString stringWithContentsOfURL:url

In theory, from any sane read of the docs, "webpage" should end up with the html of the given url in it.



After many hours of struggling with that code, and a number of trips to google and a couple of mac programming sites, I found one lone comment burried in a mailing list thread that said "oh, yeah, you can only use a file:// URL with that method."

Now I'm not sure that was a definitive statement from anyone @apple.com, since the post was from "email@hidden.domain" thanks to the web presentation of a mailing list archive. So either the docs are WOEFULLY inadequate, OR, the code has a HUGE bug in it. I'll let Apple's engineers figure that out. radr://5539874

Labels: , , ,


Post a Comment

<< Home