iPhone Objective-C Simplest Way to get a stock quote

oberbaum picture oberbaum · Feb 15, 2010 · Viewed 10k times · Source

Im wondering what is the simplest way to get the current price of a stock from say yahoo finance (or similar) in objective-C For the iPhone SDK.

Simple is the key, I am looking for current price, and days movement.

I havent had much luck finding an iPhone code example or library.

regards

Answer

mikecsh picture mikecsh · Feb 15, 2010

Use an NSURLRequest object to retrieve the data at this address:

http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv

Using [NSString stringWithFormat:] to change the AAPL to the stock ticker you want to use. The retrieved data is in CSV format so you will need to parse that to get the individual values you require. This can be done in this simple case using [NSString componentsSeparatedByString: @","] to retieve an array which you can parse using two loops.