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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:03:07+00:00 2026-05-27T06:03:07+00:00

My Core Data model looks like this: article <—>> category Is it even remotely

  • 0

My Core Data model looks like this:

article <--->> category

Is it even remotely possible to use NSFetchedResultsController to produce a UITableView that looks something like this?

Category 1
  - Article A
  - Article B
  - Article C
Category 2
  - Article A
  - Article D
  - Article E
  - Article F
Category 3
  - Article B
  - Article C

Specifically, I’m interested in the (edge?) case where each UITableView section has a unique title (eg, “Category 1”, “Category 2”), but the same object can exist in multiple sections (eg, Article A exists in both Category 1 and Category 2).

I have scoured Apple’s Core Data docs and have spent two days perusing questions here, but alas, no luck even finding out whether this is possible, let alone how to implement it. Thanks for any help or pointers to a previously answered question. I certainly couldn’t find it.

  • 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-27T06:03:08+00:00Added an answer on May 27, 2026 at 6:03 am

    Yes, it’s easy, though there are a million ways to do it.

    Your view controller should be the “data source” of the UITableView, and returns information about the number of rows there are and then the contents of each individual row.

    There is a concept of a “section” in a tableview, you might choose to have one for each category.

    For example, you could create an NSFetchedResultsController to find the categories you want to display, and use that to populate the table view sections, and then each category would have an articles many-to-many relationship, to populate the rows in each section.

    Something like this should get you started (assuming your category and article entities both contain a title property):

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
       // return the number of categories
        [[self.categoryResultsController fetchedObjects] count];
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
    {
      // return the title of an individual category
        [[self.categoryResultsController.fetchedObjects objectAtIndex:section] valueForKey:@"title"];
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
      // return the number of articles in a category
      MyCategory *category = [self.categoryResultsController.fetchedObjects objectAtIndex:section];
    
      return category.articles.count;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
      // fetch a cached cell object (since every row is the same, we re-use the same object over and over)
        static NSString *identifier = @"ArticleCellIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
        }
    
        // find the category and article, and set the text of the cell
        MyCategory *category = [self.categoryResultsController.fetchedObjects objectAtIndex:indexPath.section];
    
        cell.textLabel.text = [[category.articles objectAtIndex:indexPath.row] valueForKey:@"title"];
    
        return cell;
    }
    

    You can read the documentation on these methods to figure out how to customise it further.

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

Sidebar

Related Questions

My Core Data model looks like this: alt text http://fwdr.org/lg4q The players relationship of
Lets say I have a core data model like this one: Item attributes: name
this is my core data model: I'm trying to get all LanguageEntries from a
I have a relationship in a Core Data model that feels like it wants
I have a data-structure (in plist) that looks something like this: What i have
I have a Core Data model similar to this: Company Entity companyName attribute (string)
I'm trying to use BuildExcerpts in django sphinx. My view looks something like this:
In my core data model I have a Person entity that has a to
In my Core Data model I have two entities: List and Patient. List has
I have set up a Core Data model where I have two objects, say

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.