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

  • Home
  • SEARCH
  • 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 8856697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:24:49+00:00 2026-06-14T14:24:49+00:00

I have a dictionary of arrays that is causing __NSCFDictionary objectAtIndex: errors. Can someone

  • 0

I have a dictionary of arrays that is causing __NSCFDictionary objectAtIndex: errors.

Can someone tell me why? The dictionary clearly has at least 1 array at the time of the error.

 NSError *error;
 responseString = [[NSString alloc] initWithData:self.responseData2 encoding:NSUTF8StringEncoding];

/* response string contains this:
   {"words":
     {
    "word": {"rowsreturned":0,"id":"-1","date":"","word":"","term":"","definition":"","updated_on":""}
     },
    "status":"",
    "rowsreturned":""
  }
*/

 NSDictionary *json = [NSJSONSerialization JSONObjectWithData:self.responseData2 options:kNilOptions error:&error];

 NSArray *todaysWord = [[json objectForKey:@"words"] objectForKey:@"word"];

 //error here -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance
 NSDictionary *word = [todaysWord objectAtIndex:0];
  • 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-14T14:24:51+00:00Added an answer on June 14, 2026 at 2:24 pm

    In your case [[json objectForKey:@"words"] objectForKey:@"word"]; is returning a dictionary and not an array. Try doing the following,

    id wordParam = [[json objectForKey:@"words"] objectForKey:@"word"];
    
    if ([wordParam isKindOfClass:[NSArray class]]) {
      NSDictionary *word = [(NSArray *)wordParam objectAtIndex:0];
    } else if ([wordParam isKindOfClass:[NSDictionary class]]) {
      NSDictionary *word = (NSDictionary *)wordParam;
    } else {
      NSLog(@"error. %@ is not an array or dictionary", wordParam);
    }
    

    Your response string also shows that value for word is,

    {"rowsreturned":0,"id":"-1","date":"","word":"","term":"","definition":"","updated_on":""}
    

    which is a dictionary with key value pairs as rowsreturned:0, id:-1 etc..

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

Sidebar

Related Questions

I have a dictionary plist. That dictionary has A-Z arrays which have names in
I have a dictionary that has keys associated with lists. mydict = {'fruits': ['banana',
I am trying to build an array that contains arrays of dictionary objects in
I am trying out arrays of strings in C. I have a dictionary array
So I have a dictionary in a dictionary with arrays. I am trying to
Does VBA have dictionary structure? Like key<>value array?
I have a plist file which is an array of dictionaries. Where each dictionary
Have Dictionary <Int64, byte> that gets used a lot. I mean in a loop
I have a method that I want to pass in a couple of arrays
I have a dictionary whose keys are strings and values are numpy arrays, e.g.:

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.