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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:35:48+00:00 2026-06-04T18:35:48+00:00

I have a NSDictionary (parsed from JSON using JSONObjectWithData , if that’s relevant) that

  • 0

I have a NSDictionary (parsed from JSON using JSONObjectWithData, if that’s relevant) that looks like:

{
ids =     (
    49939999,
    44754859,
    14424892,
    16311801,
    16045487,
    31247745,
    5982852
);
"next_cursor" = 0;
"next_cursor_str" = 0;
"previous_cursor" = 0;
"previous_cursor_str" = 0;
}

when logged using NSLog(@"%@", jsonResult);.

I’m accessing ids with friends = [jsonResult objectForKey:@"ids"];, and would expect friends to be of type NSArray, but apparently it’s of type __NSCFArray. Why?

I then try to get friends’ size using [friends count] but this creates an exception when run.

How to get count of a NSDictionary-stored “NSArray”?

UPDATE: Code

        NSError *jsonError = nil;
        id jsonResult = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonError];
        if (jsonResult != nil) {



            self.friends = [jsonResult objectForKey:@"ids"];

            NSLog(@"%@", self.friends);

            NSLog(@"%@", [self.friends class]);

            NSLog(@"%@", [self.friends count]);

            dispatch_sync(dispatch_get_main_queue(), ^{
                [self.tableView reloadData];
            });                
        }
  • 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-04T18:35:50+00:00Added an answer on June 4, 2026 at 6:35 pm

    NSCFArray is a subclass of NSArray. Most of the time when you deal with an NSArray, that’s the concrete class you’re dealing with. This is what it means in the documentation when it says NSArray is a class cluster.

    Your crash is because when you try to print [friends count], you use the format string @"%@". %@ tells NSLog to expect an object, but this is an NSUInteger. Instead, you should do NSLog(@"%lu", (unsigned long)[friends count]). (If you’re not entirely clear on the idea of format specifiers, Apple has a handy guide.)

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

Sidebar

Related Questions

I have a JSON string (from PHP's json_encode() that looks like this: [{id: 1,
I have an Array of NSDictionary objects. These Dictionaries are parsed from a JSON
I have this json string by getting a response from using singleton client(RestKit). [
the question explains it all. For instance, if I have a NSDictionary like this
I have an NSArray of NSDictionary objects which I would like to be able
I have an NSArray full of NSDictionary object. This structure is built from a
I have a JSON file, and i need to extract values from it and
I have xml data that is retrieved from a server and I need to
I have an app that when first launched reads in its data from a
I have a few NSManagedObject classes. I am pulling down some JSON data from

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.