Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:08:36+00:00 2026-06-07T15:08:36+00:00

I’m trying to parse data from yahoo finance using JSON. For some reason the

  • 0

I’m trying to parse data from yahoo finance using JSON. For some reason the app keeps crashing. It seems that the last line of code is causing the crash. When I comment that line out, no crash happens. Here’s what I have so far…. Any ideas?

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) //1
#define kLatestKivaLoansURL [NSURL URLWithString:     @"http://query.yahooapis.com/v1/public/yql?    q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AAPL%22)%0A%09%09&env    =http%3A%2F%2Fdatatables.org%2Falltables.env&format=json"] //2

#import "JsonViewController.h"

@implementation JsonViewController

- (void)viewDidLoad
{
[super viewDidLoad];

dispatch_async(kBgQueue, ^{
    NSData* data = [NSData dataWithContentsOfURL: 
                    kLatestKivaLoansURL];
    [self performSelectorOnMainThread:@selector(fetchedData:) 
                           withObject:data waitUntilDone:YES];
});
}

- (void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization 
                      JSONObjectWithData:responseData //1

                      options:kNilOptions 
                      error:&error];

NSArray* latestLoans = [json objectForKey:@"query"]; //2

NSLog(@"query: %@", latestLoans); //3

NSDictionary* loan = [latestLoans objectAtIndex:0]; /////// Where crash happens //////
}
@end

This is the error message in the console

[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6a65420
2012-07-15 01:18:29.492 Json[1730:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6a65420’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:08:39+00:00Added an answer on June 7, 2026 at 3:08 pm

    This is because your JSON is decoding to an NSDictionary instead of an NSArray. If I am seeing the yahoo response properly, you probably want to fetch objectForKey:@"results" and then objectForKey:@"quote" on that:

    NSDictionary *resultQuery = [json objectForKey:@"query"];
    NSDictionary *results = [resultQuery objectForKey:@"results"];
    NSDictionary *quote = [resultQuery objectForkey@"quote"];
    

    this is how the JSON at the url you posted is structured:

    {"query": {
         "count":1,
         "created":"2012-07-15T05:48:29Z",
         "lang":"en-US",
         "results":{
             "quote":{
                   "symbol":"AAPL","Ask":"605.00"
                     }
                   }
               }
    }
    

    Of course, you will want to expand that into proper validation steps, but the key is to know what is actually inside that returned JSON (I looked at your URI, and there were no arrays anywhere).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.