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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:21:42+00:00 2026-05-31T23:21:42+00:00

I need to put the values retrieved using a Fetch Request from my core

  • 0

I need to put the values retrieved using a Fetch Request from my core data graph into an array, but not entirely sure how to go about this.

I’m using the following to perform the fetch:

    NSString *entityName = @"Project"; // Put your entity name here
        NSLog(@"Setting up a Fetched Results Controller for the Entity named %@", entityName);

        // 2 - Request that Entity
        NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:entityName];

        // 3 - Filter it if you want
        request.predicate = [NSPredicate predicateWithFormat:@"belongsToProject = %@", _selectedProject];

        // 4 - Sort it if you want
        request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"dateTaken"
                                                                                         ascending:YES
                                                                                          selector:@selector(localizedCaseInsensitiveCompare:)]];
        // 5 - Fetch it
        self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
                                                                            managedObjectContext:self.managedObjectContext
                                                                              sectionNameKeyPath:nil
                                                                                       cacheName:nil];


[self performFetch];

As you can see, i’m filtering the values that come back using an NSPredicate.

How would I get these values into an array and also be able to select individual attributes for the entity once they are in the array, for example the project.description or project.name?

Thanks to Eimantas I’ve got the objects in an array, however I still need to do two things:

  1. Loop through the array and output the data into some HTML
  2. Individually select attributes from the array, for example, the project description.

I’m using the following for loop to do the first:

for (int i=0; i < [projectListArray count]; i++) 
{
        NSString *tmp = (NSString *)[projectListArray objectAtIndex:i];
}

However, this is returning the error:

-[Project length]: unrecognized selector sent to instance 0x1b9f20
2012-03-28 10:48:35.160 Project App[3973:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Project length]: unrecognized selector sent to instance 0x1b9f20'

It appears as though i might not be incrementing?

  • 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-31T23:21:43+00:00Added an answer on May 31, 2026 at 11:21 pm

    [self.fetchedResultsController fetchedObjects] returns the array of fetched objects.

    update

    It’s better to use fast enumaration, not a for loop:

    for (Project *project in projectListArray) {
        NSString *projectDescription = [project valueForKey:@"description"];
    }
    

    You’re getting the exception because you’re casting an object to NSString while it’s a pointer to (I presume) Project managed object.

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

Sidebar

Related Questions

I need to put a custom hover menu from http://www.addthis.com/help/toolbox , but Rails uses
I have about 10million values that I need to put in some type of
The value of ig is being transfered fine, but I need to put this
I need to put an LDAP contextSource into my Java EE container's JNDI tree
All I need to know is how to put a PDF page into a
I need to compare one given value with a retrieved values. I do this
Using an application's API, I'm able to retrieve data as a JSON and put
I need to put an alpha blended gradient border around an image. My problem
I need to put a control to the right of my MenuStrip. The MenuStrip
I need to put a one second delay in this jQuery function so that

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.