Okay I am learning about arrays and how to work with them like I used to…… (Used to do alot of scripting but now am trying to learn to develop ipad and iphone app’s
But my issue is I have it where it pulls a bunch of data from yahoo finance with a for loop..
But now my issue is how can I work with just one peice of the array data that has been pulled
here is my example
-(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";
}
}
}
But now I want to do something like
year.text=StockOpens[5];
How can I do this.
Starting in Xcode 4.4 (LLVM 4.0), literals can be used for C-style subscripting in Objective-C.
LLVM has documented the use of literal here: Objective-C Literals
Note: Because Clang will translate the literal usage, in this case to
objectAtIndexedSubscript:, the OS X v10.8 (or iOS 6) Foundation framework is required.