好吧我正在學習數組以及如何像以前一樣使用它們......(用於做很多腳本,但現在正在嘗試學習開發ipad和iphone應用程序的Objective-C數組學習
但我的問題是,我有它它就會從雅虎財經與for循環一組數據..
但現在我的問題是,我怎麼能與陣列的數據只是一個peice的已工作拉
這裏是我的榜樣
-(IBAction) clicked:(id)sender {
NSString * StockOneYahooFinance = [NSString stringWithFormat:@"http://finance.yahoo.com/q/hp?s=S+Historical+Prices"];
NSString * PulledStockOne = [NSString stringWithContentsOfURL:[NSURL URLWithString:StockOneYahooFinance] encoding:1 error:nil];
for (i=1;i<=10;i++){
NSString *StartPulling = [[PulledStockOne componentsSeparatedByString:@"nowrap align="] objectAtIndex:i];
NSString *StartOpen = [[StartPulling componentsSeparatedByString:@">"] objectAtIndex:3];
NSString *Open = [[StartOpen componentsSeparatedByString:@"<"] objectAtIndex:0];
NSString *StartClose = [[StartPulling componentsSeparatedByString:@">"] objectAtIndex:9];
NSString *Close = [[StartClose componentsSeparatedByString:@"<"] objectAtIndex:0];
NSMutableArray *StockOpens = [[NSMutableArray alloc] initWithCapacity:6];
[StockOpens addObject:Open];
sixtyday.text = [OpenValues objectAtIndex:10];
nintyday.text = [CloseValues objectAtIndex:10];
if ([OpenValues objectAtIndex:10]=[OpenValues objectAtIndex:11] {
sevenday.text = @"Plus One";
}
}
}
但現在我要像做
year.text=StockOpens[5];
我怎樣才能做到這一點。
字典鍵有類似的東西嗎?太好了! – 2012-07-28 17:32:23
是的!我通過鏈接到LLVM的文檔更新了我的解決方案。 – jtomschroeder 2012-07-28 17:36:11
請注意,這也需要使用iOS 6或OS X 10.8 SDK附帶的Foundation版本。 – 2012-07-28 18:07:06