iosobjective-csdkstock

iPhone Objective-C Simplest Way to get a stock quote


I'm 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 haven't had much luck finding an iPhone code example or library.


Solution

  • 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.