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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:31:00+00:00 2026-05-13T19:31:00+00:00

What I want to do is pretty simple. In my UITableViewController, I want to

  • 0

What I want to do is pretty simple. In my UITableViewController, I want to load data from multiple NSFetchedResultControllers (I have multiple entities in my data model) and put data from each one into a different section in the table view. So for example, all the fetched items from the first NSFetchedResultController would go in section 0 in the UITableView, the fetched items from the other one goes into section 1, etc.

The Core Data template project doesn’t demonstrate how to do this. Everything (mainly the index paths) is coded without taking sections into account (there are no sections in the default template) and everything is taken from a single NSFetchedResultController. Are there any example projects or documentation that demonstrates doing this?

Thanks

  • 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-13T19:31:00+00:00Added an answer on May 13, 2026 at 7:31 pm

    Assume for a moment the following in your header (code below will be slightly sloppy, my apologies):

    NSFetchedResultsController *fetchedResultsController1; // first section data
    NSFetchedResultsController *fetchedResultsController2; // second section data
    

    Let the table know you want to have 2 sections:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 2; // you wanted 2 sections
    }
    

    Give it the section titles:

    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
        return [NSArray arrayWithObjects:@"First section title", @"Second section title", nil];
    }
    

    Let the table know how many rows there are per sections:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        if (section == 0) {
            return [[fetchedResultsController1 fetchedObjects] count];
        } else if (section == 1) {
            return [[fetchedResultsController2 fetchedObjects] count];
        }
    
        return 0;
    }
    

    Build the cell:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        ... // table cell dequeue or creation, boilerplate stuff
    
        // customize the cell
        if (indexPath.section == 0) {
            // get the managed object from fetchedResultsController1
            // customize the cell based on the data
        } else if (indexPath.section == 1) {
            // get the managed object from fetchedResultsController2
            // customize the cell based on the data
        }
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should be pretty simple question here. I have @Html.EditorFor(model=>model.Training) I dont want to show
Should be pretty simple: I have an InputStream where I want to peek at
I want to do something pretty simple but have yet am having a hard
I have something pretty simple I want to do. I'm still working through all
What I want to do is pretty simple. I would like to have sync
I have a pretty simple user control that I want to bind a ScaleTransform
This should be pretty simple. I have an Int and I want to convert
OK. So I have a pretty simple question: I want to be able to
This is pretty simple and straightforward. I want to throw a 503 error from
I have a pretty simple Rails app and I want send an e-mail when

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.