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

The Archive Base Latest Questions

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

Example: I have an Cat entity with an catAge attribute. In the data modeler,

  • 0

Example: I have an Cat entity with an catAge attribute. In the data modeler, I configured catAge as int with a max of 100. Then I do this:

[newManagedObject setValue:[NSNumber numberWithInt:125] forKey:@"catAge"];

// Save the context.
NSError *error = nil;
if (![context save:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}

I’m getting an error in the console, like this:

2010-06-12 11:40:41.947 CatTest[2250:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1610 UserInfo=0x10164d0 "Operation could not be completed. (Cocoa error 1610.)", {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1610.)";
    NSValidationErrorKey = catAge;
    NSValidationErrorObject = <NSManagedObject: 0x10099f0> (entity: Cat; id: 0x1006a90 <x-coredata:///Cat/t3BCBC34B-8405-4F16-B591-BE804B6811562> ; data: {
    catAge = 125;
    catName = "No Name";
});
    NSValidationErrorPredicate = SELF <= 100;
    NSValidationErrorValue = 125;
}

Well, so I have an validation error. But the odd thing is, that it seems the MOC is broken after this. If I just tap “add” to add another invalid Cat object and save that, I’m getting this:

2010-06-12 11:45:13.857 CatTest[2250:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1560 UserInfo=0x1232170 "Operation could not be completed. (Cocoa error 1560.)", {
    NSDetailedErrors =     (
        Error Domain=NSCocoaErrorDomain Code=1610 UserInfo=0x1215f00 "Operation could not be completed. (Cocoa error 1610.)",
        Error Domain=NSCocoaErrorDomain Code=1610 UserInfo=0x1209fc0 "Operation could not be completed. (Cocoa error 1610.)"
    );
}

That seems to report two errors now. BUT: When I try to delete now an valid, existing object from the table view (using the default core data template in a navigation-based app), then the app crashes! All I get in the console is:

2010-06-12 11:47:18.931 CatTest[2250:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1560 UserInfo=0x123eb30 "Operation could not be completed. (Cocoa error 1560.)", {
    NSDetailedErrors =     (
        Error Domain=NSCocoaErrorDomain Code=1610 UserInfo=0x1217010 "Operation could not be completed. (Cocoa error 1610.)",
        Error Domain=NSCocoaErrorDomain Code=1610 UserInfo=0x123ea80 "Operation could not be completed. (Cocoa error 1610.)"
    );
}

…so no idea where or why it crashes, but it does. So the question is, what are the neccessary steps to take when there’s an validation error?

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

    The crash you are experiencing is probably not related to the previous errors, but without the relevant source code this is almost impossible to tell. Anyway, in order to deal correctly with the situation you describe, you have two alternatives. You can either report the error to the user, so that he/she can modify the offending value violating the validation check and then save the context, or you must delete from the context the NSManagedObject.

    There is an overall better strategy. Instead of letting Core Data apply automatically validation before saving the context (using either automatically generated methods or your own methods), do yourself a validation test before taking an action. Do this using the NSManagedObject methods

    - (BOOL)validateForInsert:(NSError **)error;
    - (BOOL)validateForUpdate:(NSError **)error;
    - (BOOL)validateForDelete:(NSError **)error;
    

    If these methods return YES, you can proceed. Otherwise, as before alert the user and let him/her modify the object as needed or delete the object. The difference with respect to the previous situation is that in this case you have not saved the context. You save the context only when the previous methods return YES, so you are sure that saving will succeed.

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

Sidebar

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This works for me: \makeatletter\newenvironment{bc_box}{% \begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}}{\end{minipage}\end{lrbox}% \colorbox{bg}{\usebox{\@tempboxa}} }\makeatother \newenvironment{bashcommands}{ \begin{bc_box}\ttfamily\color[RGB]{222,222,222}… May 15, 2026 at 8:10 pm
  • Editorial Team
    Editorial Team added an answer Actually, after near than 3 years of inactivity (version 1.2.2… May 15, 2026 at 8:10 pm
  • Editorial Team
    Editorial Team added an answer $crumb = explode("/", $path); print "<div class='breadcrumbs'>"; $newpath = '';… May 15, 2026 at 8:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.