I’ve looked into this a lot on stack overflow and have found some instances where it may work for what I want to do, but I’m not gonna lie, I’m a tad lost. I have a very simple string that shows up on a webpage that i want to read into the application, parse it, then display it inside some UITextFields. The URL is mtgox.com/data/code/ticker.php. It’s a php page that yields a simple JSON string, a one liner, looking like the following:
{"ticker":{"high":14.6999,"low":14.04,"avg":14.379509781,"vol":10981,"last":14.44278,"buy":14.4302,"sell":14.44278}}
How can I read this string into my application and then parse it? I was thinking of possibly using the UIWebView class and the stringByEvaluatingJavaScriptString method on the site, but I don’t know much about javascript, nor do I know if that would work.
I’ve seen some people mentioning the use of a JSON library, but don’t know if that’s what will be the best for what I need, and if that will even work; and I feel that might be a tad overkill given I’m only parsing one line.
If you insist not to use JSON parser (library installation and other framework config hasle), the
code below has been tested and work fine for your URL:
Place this code in the view controller that has the textfield.
Hopefully it help to solve your problem.