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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:00:55+00:00 2026-05-28T07:00:55+00:00

I’m having a lot of difficulty getting core data to work in my application.

  • 0

I’m having a lot of difficulty getting core data to work in my application. I’m perfectly comfortable with core data in a table view controller and even with core data in a single view application. I’m unable however to get my program to function properly in with multiple view controllers.

I’ve read through Zarra’s core data book and bought pro core data for iOS and have gone through the projects listed but every one of them is used in a TableView controller. with the exception of the shapes application in pro core data for iOS.

Does anyone know of any examples (code or tutorials) that would demonstrate how to do a program with multiple view controllers and core data?

What I would like to do is have buttons on the first (instead of tableview cells) that will segue to the the next viewController. On the second view controller I would like that information populated with information from the set of the first entity,

so I have something like this so far where the first entity is:

House

  • houseName (attribute)
  • occupants (relationship)

Person

  • personName (attribute)
  • household (relationship)

occupants <–>>household (one to many )

{
...
int i = //house selected on previous view controller;
NSManagedObject *people = [[self sortOccupants] objectAtIndex:i];
textField01.text = [NSString stringWithFormat:@"%@",[[people valueForKey:@"personName"]description]];
}

the sort occupants looks like this:

-(NSArray *)sortOccupants
{
NSSortDescriptor *sortPeopleInHouse = [[NSSortDescriptor alloc] initWithKey:@"personName" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortPeopleInHouse, nil];
return [[(NSSet *)[house valueForKey:@"occupants"] allObjects] sortedArrayUsingDescriptors:sortDescriptors];
}

Any Ideas would be great but if you can point me to sample code that would show this I would be most appreciative.

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-28T07:00:56+00:00Added an answer on May 28, 2026 at 7:00 am

    The way I would approach this is to generate NSManagedObject subclasses for your entities (makes it much more readable and type-safe).

    Then, I would create a new init method in the second view controller. initWithHouse:(House *)house or something:

    @property (nonatomic, strong) House  * currentHouse;
    @property (nonatomic, strong) NSArray * sortedOccupants; // Array of People objects
    
    -(id) initWithHouse:(House *)house
    {
      if (self = [super init])
      {
          // Managed Object Context available from [currentHouse managedObjectContext]
          currentHouse = house;
          sortedOccupants = [self sortOccupants:house.occupants];
      }
      return self;
    }
    
    -(NSArray *)sortOccupants: (NSSet *)occupants
    {
        NSSortDescriptor *sortPeopleInHouse = [[NSSortDescriptor alloc] initWithKey:@"personName" ascending:YES];
        NSArray *sortDescriptors = [NSArray arrayWithObjects:sortPeopleInHouse, nil];
    
        return [occupants allObjects] sortedArrayUsingDescriptors:sortDescriptors];
    }
    

    Hope that helps.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.