I am trying to get the latest updated entry in my JSON http://data.mtgox.com/api/1/BTCUSD/trades/fetch but unfortunately the latest updated entries appear at the bottom and not at the top of the JSON list. Here is my code
- (void)fetchedlatestData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData //1
options:kNilOptions
error:&error];
NSArray* bitcoinPrices2 = [json objectForKey:@"return"]; //2
//Get the Last Price
NSDictionary* latest = [bitcoinPrices2 objectAtIndex:0];
NSDictionary* latestPrice = [latest objectForKey:@"price"];
NSLog(@"Data: %@", latestPrice);
By using objectAtIndex:0
I can get the first entry, but how would I go about getting the very last entry as the index number would not be consistent and the amount of entries in the JSON is not a consistent number. Would I need to reverse the order of the JSON when it comes in so the index is 0? How would I go about this? I am trying to get the last two "price" numbers to compare them and I am new to how JSON works. Thanks