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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:49:12+00:00 2026-06-13T05:49:12+00:00

I’m working on a manual migration, primarily using this stackoverflow answer as a guide:

  • 0

I’m working on a manual migration, primarily using this stackoverflow answer as a guide:
https://stackoverflow.com/a/8155531/5416

I have 3 separate entities that need to be migrated. Only one property on each is changing, and it’s changing from an integer to a string. Some of the entities seem to go through just fine, and no exceptions are being thrown, but the process is not completing. It lists a bunch of errors that are all essentially exactly the same:

Error Domain=NSCocoaErrorDomain Code=1570 \”The operation
couldn\U2019t be completed. (Cocoa error 1570.)\” UserInfo=0x2a4c2790
{NSValidationErrorObject=NSManagedObject_CCRecipeIngredient_2:,
NSValidationErrorKey=name, NSLocalizedDescription=The operation
couldn\U2019t be completed. (Cocoa error 1570.)}

Any ideas how best to troubleshoot this? If it helps, here’s the migration policy that I’m using:

- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)aSource
                                      entityMapping:(NSEntityMapping *)mapping
                                            manager:(NSMigrationManager *)migrationManager
                                              error:(NSError **)error {

    NSString *attributeName = @"foodId";

    NSEntityDescription *aSourceEntityDescription = [aSource entity];
    NSString *aSourceName = [aSourceEntityDescription valueForKey:@"name"];

    NSManagedObjectContext *destinationMOC = [migrationManager destinationContext];
    NSManagedObject *destEntity;
    NSString *destEntityName = [mapping destinationEntityName];

    if ([aSourceName isEqualToString:@"CCFood"] || [aSourceName isEqualToString:@"CCFoodLogEntry"] || [aSourceName isEqualToString:@"CCRecipeIngredient"] )
    {
        destEntity = [NSEntityDescription
                           insertNewObjectForEntityForName:destEntityName
                           inManagedObjectContext:destinationMOC];

        // attribute foodid
        NSNumber *sourceFoodID = [aSource valueForKey:attributeName];
        if (!sourceFoodID)
        {
            [destEntity setValue:@"0" forKey:attributeName];
        }
        else
        {
            NSInteger sourceFoodIDInteger = [sourceFoodID intValue];
            NSString *sourceFoodIDString = [NSString stringWithFormat:@"%i", sourceFoodIDInteger];
            [destEntity setValue:sourceFoodIDString forKey:attributeName];

        }

        [migrationManager associateSourceInstance:aSource
                          withDestinationInstance:destEntity
                                 forEntityMapping:mapping];

        return YES;
    } else
    {
        // don't remap any other entities
        return NO;
    }
}
  • 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-13T05:49:12+00:00Added an answer on June 13, 2026 at 5:49 am

    Ok, so I guess it was really just a case of me misunderstanding how this API works a bit. All of the object’s attributes do not get mapped over automatically. I was under the (mistaken) assumption that I only had to set the attributes that I was mapping.

    In the end, all I had to do was iterate over the source entity’s attributes and assign them to the destination entity.

    - (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)aSource
                                          entityMapping:(NSEntityMapping *)mapping
                                                manager:(NSMigrationManager *)migrationManager
                                                  error:(NSError **)error {
    
        NSString *attributeName = @"foodId";
    
        NSEntityDescription *aSourceEntityDescription = [aSource entity];
        NSString *aSourceName = [aSourceEntityDescription valueForKey:@"name"];
    
        NSManagedObjectContext *destinationMOC = [migrationManager destinationContext];
        NSManagedObject *destEntity;
        NSString *destEntityName = [mapping destinationEntityName];
    
        if ([aSourceName isEqualToString:@"CCFood"] || [aSourceName isEqualToString:@"CCFoodLogEntry"] || [aSourceName isEqualToString:@"CCRecipeIngredient"] )
        {
            destEntity = [NSEntityDescription
                               insertNewObjectForEntityForName:destEntityName
                               inManagedObjectContext:destinationMOC];
    
            // migrate all attributes
            NSEntityDescription *entity = [aSource entity];
            NSDictionary *attributes = [entity attributesByName];
            for (NSString *attribute in attributes) {
                if ([attribute isEqualToString:@"foodId"]) {
                    // migrate the food id
                    NSNumber *sourceFoodID = [aSource valueForKey:attributeName];
                    if (!sourceFoodID)
                    {
                        [destEntity setValue:@"0" forKey:attributeName];
                        NSLog(@"migrating %@: empty foodid", aSourceName);
                    }
                    else
                    {
                        NSInteger sourceFoodIDInteger = [sourceFoodID intValue];
                        NSString *sourceFoodIDString = [NSString stringWithFormat:@"%i", sourceFoodIDInteger];
                        [destEntity setValue:sourceFoodIDString forKey:attributeName];
                        NSLog(@"migrating %@ # %@", aSourceName, sourceFoodIDString);
    
                    }
                }
                else {
                    // not the foodid, so just pass it along
                    id value = [aSource valueForKey: attribute];
                    [destEntity setValue:value forKey:attribute];
                }
            }
    
            [migrationManager associateSourceInstance:aSource
                              withDestinationInstance:destEntity
                                     forEntityMapping:mapping];
    
            return YES;
        } else
        {
            // don't remap any other entities
            return NO;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.