iPhone Objective-C 获取股票报价的最简单方法 [英] iPhone Objective-C Simplest Way to get a stock quote

查看:43
本文介绍了iPhone Objective-C 获取股票报价的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在 Objective-C For iPhone SDK 中,从雅虎财经(或类似机构)获取股票当前价格的最简单方法是什么.

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.

我没能找到 iPhone 代码示例或库.

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

问候

推荐答案

使用 NSURLRequest 对象检索此地址处的数据:

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

使用 [NSString stringWithFormat:] 将 AAPL 更改为您要使用的股票代码.检索到的数据采用 CSV 格式,因此您需要对其进行解析以获取所需的各个值.这可以在这个简单的例子中完成,使用 [NSString componentsSeparatedByString: @","] 来检索一个可以使用两个循环解析的数组.

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.

这篇关于iPhone Objective-C 获取股票报价的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆