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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:01:44+00:00 2026-06-14T18:01:44+00:00

I have a core data setup that has 2 database entities. For the sake

  • 0

I have a core data setup that has 2 database entities. For the sake of names I’ll call them Primary and Secondary. Secondary only belong to one Primary (relationship is setup). In my main view that lists the Primary objects in a table I retrieved them and put them in an PriObject Class which stores it’s properties (including the managed object ID). The PriObject is then added to a mutable array (priArray), which is then used to fill the table with the data. All works ok so far. When I then click on the row I can log the PriObject.moID.

I can’t figure out how to lookup that object in the database so I can then add Secondary objects to it. I can’t do it by name because some Primary might have the same name.

I need to work out how to get an object back from either the URI or the ID. I have the ID so I can generate the URI if I need to.

Can’t get my head around it at all and any examples I have found while looking don’t cover what I need. What options are there?

EDIT: I am currently getting all my objects with the following.

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

NSManagedObjectContext *context = [appDelegate managedObjectContext];

NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Primary"
                                              inManagedObjectContext:context];

NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];

NSError *error;
NSArray *objects = [context executeFetchRequest:request
                                          error:&error];


if ([objects count] == 0) {
    NSLog(@"Nothing found");
} else {
    NSLog(@"Something found");
}

How can I change this for just the one using:

ObjectWithID:
  • 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-06-14T18:01:45+00:00Added an answer on June 14, 2026 at 6:01 pm

    Call the objectWithID: method on your NSManagedObjectContext instance to retrieve the instance.

    As an aside, it seems like you are making things harder on yourself with this PriObject class, it seems to be a wrapper around your NSManagedObject instances, is that right? I’d just use NSManagedObject subclasses directly, personally.

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

Sidebar

Related Questions

I have 2 core data entities: Question, and QuestionType. Every Question has exactly 1
I have the following Core Data setup: Project has-many Answer Field has-many Answer Answer
I have set up a Core Data model that includes an entity, Item with
I have Core Data setup in my app and need to fetch a bunch
Suppose I have core data entities A and B, where B points to A
I have a core data UITableView, the core data managed object has 4 properties
I have a core data object and a REST web interface that use different
I have a core data recipe object that contains an ordered list of ingredient
I've got a Core Data setup where each object has an NSDate, and a
I'm using Core data in an iOS project. I have the data model setup

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.