Question

I made an xcode project in which I logged the JSON from a YQL query. This is the output I get:

    quote =     {
AverageDailyVolume = 22235800;
Change = "+0.03";
DaysHigh = "36.60";
DaysLow = "35.55";
DaysRange = "35.55 - 36.60";
LastTradePriceOnly = "36.38";
MarketCapitalization = "37.523B";
Name = "Yahoo! Inc.";
StockExchange = NasdaqNM;
Symbol = YHOO;
Volume = 28937796;
YearHigh = "41.72";
YearLow = "23.47";
symbol = YHOO;

};

}

What i want to do is take a single line from this code. for example: "LastTradePriceOnly ="36.38"". Then i want to be able to store the value of LastTradePriceOnly (36.38) in a NSNumber/NSInteger.

the code i have in my project is mainly:

- (IBAction)enterButton2:(id)sender {
NSString *query2 = (self.queryText2.text);
NSDictionary *results2 = [yql query:query2];
NSString *respond2 = [[results2 valueForKeyPath:@"query.results"]description];
self.resultView2.text = respond2;
NSLog(@"%@",respond2);}

the query i used is placed in a textView, the query is :

select * from yahoo.finance.quote where symbol in ("YHOO")

thanks to @Larme i tried to use this method:

[[yourObject objectForKey:@"quote"] objectForKey:@"LastTradePriceOnly"]

but i couldnt get it to work.

help is much appreciated.

Was it helpful?

Solution

The solution:
Ok, so you put your response (respond2) into an NSString. That's quite strange. Let's restart from something that was a NSArray or a NSDictionary: [results2 valueForKeyPath:@"query.results"]:

[[[results2 valueForKeyPath:@"query.results"] objectForKey:@"quote"] objectForKey:@"LastTradePriceOnly"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top