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 7417093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:37:53+00:00 2026-05-29T07:37:53+00:00

I m trying to parse json returned by twitter. The json is retrieved well

  • 0

I m trying to parse json returned by twitter. The json is retrieved well and i convert it to NSDictionary,

NSLog on dictionary object works well and shows all the tweets.

NSLog(@"Twitter response: %@", dict);

but getting following error when i try to get objectForKey for any key in dict object:

2012-02-07 15:35:28.988 TestTweetApp[1525:12103] -[__NSCFArray
objectForKey:]: unrecognized selector sent to instance 0x6a2a370
[Switching to process 1525 thread 0x12103] [Switching to process 1525
thread 0x12103] 2012-02-07 15:35:28.997 TestTweetApp[1525:12103] *
Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason: ‘-[__NSCFArray objectForKey:]:
unrecognized selector sent to instance 0x6a2a370’
*
First throw call stack: (0x176e052 0x1a40d0a 0x176fced 0x16d4f00 0x16d4ce2 0x3044 0xd306 0x2048445 0x2049ecf 0x2049d28 0x20494af
0x9ca1fb24 0x9ca216fe) terminate called throwing an
exceptionsharedlibrary apply-load-rules all

code for viewDidLoad() function is:

- (void)viewDidLoad
{
    [super viewDidLoad];

    TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString: @"https://api.twitter.com/1/statuses/public_timeline.json?screen_name=[SOME_USER_NAME]&include_entities=true"] parameters:nil requestMethod:TWRequestMethodGET];

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
    {
        if ([urlResponse statusCode] == 200) 
        {
            NSError *error;  

            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];

            NSLog(@"Twitter response: %@", [dict objectForKey:@"entities"]);
        }
        else
            NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
    }];

}
  • 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-05-29T07:37:54+00:00Added an answer on May 29, 2026 at 7:37 am

    It seems that your response is a NSArray instead of a NSDictionary. Try

    NSLog(@"%@", [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error]);
    

    before your

    NSDictionary *dict... 
    

    line and see the format.
    Then move it to an NSArray and access the elements properly.

    NSArray *response = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
    NSLog(@"elements = %@", response);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse JSON returned from a curl request, like so: curl 'http://twitter.com/users/username.json'
I am trying to parse the JSON returned here: http://www.waterwayguide.com/map/php/bridge.php?ll=25.514339,-80.076164 However, I can't parse
I'm trying to upload and parse json files using django. Everything works great up
http://pastebin.com/rXbeKqAa Hi all I have been trying to parse the above JSON into a
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I am trying to parse a json string straight into a managed object. The
I'm trying to parse some JSON object strings that I'm getting using gson-1.6.jar I
I'm trying to parse a very simple json object with 1 value. (ocUnit test
I'm trying to parse the JSON returned from SocialMention. Here's an example of what
I'm trying to parse returned json but can't access the data. Trying to access

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.