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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:53:43+00:00 2026-05-21T17:53:43+00:00

This is something i just can’t figure out working with Core Data. I want

  • 0

This is something i just can’t figure out working with Core Data. I want to work with an NSFetchedResultsControllerDelegate and the usual code i’ve seen so far is easy to understand but always based on a one entity model. So you want to show in your table all the “events”, you do a fetch request on the Event entity and there, you are set to go.

The thing is, my model is:

City (one-to-one) Company (one-to-many) Employees

My table would need to show the employees, but the fetch would have to be based on the City, in order to retrieve the Company and then the Employees, right? I’m completely lost at this, i just don’t see how to do the fetch.

Because if i fetch City or Company and i put Employees in an NSMutableSet, don’t i loose all the authomatic UITableViewController syncing? For instance, if i do it like this, i will be unable to do something like

- (NSInteger)tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section {
    id <NSFetchedResultsSectionInfo> sectionInfo = 
        [[_fetchedResultsController sections] objectAtIndex:section];
    return [sectionInfo numberOfObjects];
}
  • 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-21T17:53:44+00:00Added an answer on May 21, 2026 at 5:53 pm

    You data model should have reciprocal relationships such that when you fetch any particular object, you have immediate access to all related objects.

    In your case, a data model with reciprocal relationships would look something like:

    City{
        company<-->Company.city
    }
    
    Company{
        city<-->City.company
        employees<-->>Employee.company
    }
    
    Employee{
        company<<-->Company.employees
    }
    

    So, if you have an Employee object, you find the company with self.company and the city by self.company.city (in most case the actual self is unnecessary and I use it for illustration purposes.) If you have a Company object, you find employees in self.employees and the city in self.city. If you have a City object you would find all the employees with self.company.employees.

    Relationships are what actually create the object graph at the heart of Core Data. You use fetches to find one group of objects in the graph and then you “walk” the relationships outward from those objects to find all the related data. It is the reciprocal relationships that make it possible to go back and forth across the relationships in both directions.

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

Sidebar

Related Questions

There's something wrong with my code or I'm just not understanding this fully. I
This code does not seem to compile, I just need to write something to
I know this is something easy but I just can't see it. Can anyone
with jquery,how can i do something just after the dom loaded,i write like this:
This has got to be something I just missed, but how do I add
Right now we just use something like this stopWatch.Start(); try { method(); } finally
This is likely going to be an easy answer and I'm just missing something,
I am still learning jQuery and have come up against something I just can't
Trying to get my project updated to MVC3, something I just can't find: I
Hi I'm sure there's query for this kind of operation, but I just can't

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.