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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:00:23+00:00 2026-05-29T07:00:23+00:00

hi :) I have a similarly issue like in Working with the same NSManagedObjectContext

  • 0

hi 🙂 I have a similarly issue like in Working with the same NSManagedObjectContext in multiple tabs
background:

My managedObjectContext (further MOC) is initialised in my appDelegate class and passed throught to multiple tabs by
myViewController.managedObjectContext = self.managedObjectContext; or in the init method with self.managedObjectContext = pContext;
the flow is: the first view is a simple list of collections. The collections are fetched with a NSFetchedResultsController (myViewController : UITableViewController<NSFetchedResultsControllerDelegate>). By selecting one, you navigate deeper, but still passing this MOC.
In the next controller (detailsViewController) I list up some items of this collection what I can interact with (set switches for instance).
I also have an editingObjectContext:

// DetailsViewController.m
NSManagedObjectContext* editingContext = [[NSManagedObjectContext alloc] init];
[editingContext setPersistentStoreCoordinator:[managedObjectContext persistentStoreCoordinator]];
self.editingObjectContext = editingContext;

Now my issue: because my view has to rotate, I am using the folowing trick:

// DetailsViewController.m
DetailsView *localAct = [[DetailsView alloc] initWithManagedObjectContext:managedObjectContext ... ]
DetailsView *localSen = [[DetailsView alloc] initWithManagedObjectContext:managedObjectContext ... ]

UITableView *localContainerView = [[UITableView alloc] init];
self.containerView = localContainerView;
[localContainerView release];
//[...]
[containerView addSubview:actuatorView];
self.tableView = containerView;

further I have a button to manage this items (which of them shall be shown and which not). This button just reloads the table with a new fetchResult.

// DetailsView.m
- (void) manageItems{
managing = !managing;
[viewController setIsManaging:managing]; // parent
self.fetchedResultsController = nil;

NSError *error = nil;
[[self fetchedResultsController] performFetch:&error];

[self reloadData];
[self updateBarButton];
}

The method for putting the items into the context looks so:

// DetailsViewController.m
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// init + create predicate
NSSet* set = [sen filteredSetUsingPredicate:predicate];
if( [set count] > 0 )
{
    for( Act* act in set )
    {
        [editingObjectContext deleteObject:act];
    }
}
else
{
    Act* act = [NSEntityDescription insertNewObjectForEntityForName:@"Act" inManagedObjectContext:editingObjectContext];

    // do things
}
NSError *error = nil;
[[detailView fetchedResultsController] performFetch:&error];

[self.containerView reloadData];
[detailView reloadData];
}

but after I selected the items in the managed view and clicked save (manageItems), the view doesn’t show them :/ i have to switch the tab or to navigate in an other controller (parent or deeper) to actualize it.
my ViewWillAppear method:

// DetailsViewController.m
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
DetailsView *detailView = se ? senView : actView;
// [do uninteresting stuff]
[detailView.fetchedResultsController performFetch:nil];
[self.tableView reloadData];
// [do uninteresting stuff]
}

and viewWillDisapper calls

- (void)saveChanges
{
if( ![editingObjectContext hasChanges] )
    return;

// send save-command to server
}

In an earliert Verison where there was only 1 view it worked and I haven’t changed realy much… :/ so I don’t understand why the MOC is acting like it does. The “manageItems” part is nearly equal, its just a level deeper in the new version (in the DetailsView instead of the controller) …

if someone can tell me what I can try (always saving to server when switch between managing and normal isn’t a solution because the delay in the response from the server is to high for the refresh, so I have the less to flip the view. Also refreshing the views with self.tableView / detailView / self.containerView refresh brings the same result :/ ).

and a second issue: I can’t call the “editingObjectContext save:” method after sending to server, because it’s throwing errors and don’t save at all to local database.

Error in handleChangeResponse:
Error Domain=NSCocoaErrorDomain Code=133020 “The operation couldn’t be completed. (Cocoa error 133020.)” UserInfo=0x4d8bb90 {conflictList=(
“NSMergeConflict (0x5a2fac0) for NSManagedObject (0x5a46a80) with objectID ‘0x5a46420 ‘ with oldVersion = 7 and newVersion = 8 and old object snapshot = {\n iconName = noicon;\n […] ;\n} and new cached row = {\n iconName = noicon;\n […] \n}”
)}

if you have questions or need some more code (i.e. of the older version) then just ask 😉

thanks in anticipation 🙂

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

    It seems like I have the solution! Since IOS 5.0 there is a new method for NSManagedObjectContext :

    [managedObjectContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy];
    

    Found on http://pauloliveira.net/tech/core-data-merging-conflicts
    Setting this attribute to the top-level MOC (in my case in the appDelegate) and no-where else! clears my merging problems 😉

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

Sidebar

Related Questions

I have a similar issue like here: http://social.msdn.microsoft.com/forums/en-US/biztalkgeneral/thread/87d5a6ec-04ee-4c6f-8267-f526ee105f0b I have an asp.net web page
I would like to address such a issue: I have a HTML form (like
I have a working Python 2.6 code using matplotlib, and would like to get
I have a local site (IIS6, although similar issue with a totally different site
my issue lokks similar to this one: (link) but i have one-to-many association: <set
I have created a taskbar using tabcontrols which works similarly to the Windows taskbar.
I have similar instances of the same web application running across many domains. I
I have a few tables that have similar fields but not exactly the same.
I'm working on a project in Grails 2.0.RC1 and I'd like to be able
I have been working all night and yesterday on this header section in css,

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.