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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:20:13+00:00 2026-05-23T20:20:13+00:00

I am new to core data so please excuse me if I get some

  • 0

I am new to core data so please excuse me if I get some of the terms wrong.

I have several objects in my xcdatamodel file. They are all inter connected with relationships and inverse relationships. If I connect two of these objects with the following code the inverse relationship is not set.

[managedObj1 setValue: managedObj2 forKey:@"relatiohipName"]; 

I seem to have to manually set the inverse relationship myself with the following code

[managedObj1 setValue: managedObj2 forKey:@"relatiohipName"];
[managedObj2 setValue: managedObj1 forKey:@"inverseRelatiohipName"];

This seems wrong to me but its the only way I can seem to get the mechanism to work. I have looked at the sqlite DB after running the first block of code and the inverse relationship is not filled in but if I run the second code the relationship is there.

Also, it seems like once I create an object in Core Data I can’t alter it after that. The dp remains the same. Once I exit the app and restart it I seem to lose all the relationships and attributes of the object. the resulting objects in my code have nothing but nil member variables.

EDIT:

The commented out stuff is the way it was done before and the uncommented stuff is how I’m doing it now with no luck.

Here is where I am creating the objects:

NSEntityDescription* mobileEntity = [NSEntityDescription entityForName:@"WebServiceAuthService_mobileAdvertisementVO" inManagedObjectContext:managedObjectContext];
WebServiceAuthService_mobileAdvertisementVO *newObject = [NSEntityDescription insertNewObjectForEntityForName:[mobileEntity name] inManagedObjectContext:managedObjectContext];
//WebServiceAuthService_mobileAdvertisementVO *newObject = [NSEntityDescription insertNewObjectForEntityForName:@"WebServiceAuthService_mobileAdvertisementVO" inManagedObjectContext:managedObjectContext];    

Here is where I am assigning one of the objects member variables:

[self setValue:newChild forKey:@"advertisement"];
            //self.advertisement = newChild;

Here is where I am saving the context:

NSError *error = nil;
if (managedObjectContext != nil) 
{
    if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) 
    {
        DLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

}
  • 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-23T20:20:14+00:00Added an answer on May 23, 2026 at 8:20 pm

    Important safety tip. If you subclass NSManagedObject DO NOT use @synthesize for your member variables. Use @dynamic instead.

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

Sidebar

Related Questions

I'm new to core data and try to get all children objects of various
I'm pretty new to Core Data and managed to get the NSTableView to show
I'm new with Core Data and there are some issues that I don't understand
I am new to Core Data. I have noticed that collection types are not
I have a view that creates a new core data managed object, and fills
I'm new to Core Data, and am struggling with some of it conceptually (relative
I am new to core data therefore I have got few questions. I'll ask
I am fairly new to core data technology and i searched a lot on
I have just installed phpMyAdmin on my new Fedora Core 10 dedicated server. I
I'm new to iPhone development, and doing some experimentation with Core Animation. I've run

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.