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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:06:55+00:00 2026-06-14T06:06:55+00:00

I have an app that uses Core Data and it gets its ManagedObjectContext by

  • 0

I have an app that uses Core Data and it gets its ManagedObjectContext by using UIManagedObject. From reading, I see that I am not suppose to save the context directly – rather I should depend on autosaving of UIManagedObject or use saveToURL:… My issue is that I want to validate the data being stored in my entity. I have constraints on the entity that specify that the min length for the string properties is 1. However, I can create a new object, assign its properties empty strings, and save the file. In the completion handler of saveToURL:… it always has a true success value. I then created my own validator for the name property of my entity. I used sample code from the Core Data Programming Guide –

-(BOOL)validateName:(id *)ioValue error:(__autoreleasing NSError **)outError 

{
    if (*ioValue == nil) 

    {
        if (outError != NULL) 

        {
            NSString *errorStr = @"nil error";

            NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:errorStr

                forKey:NSLocalizedDescriptionKey];

            NSError __autoreleasing *error = [[NSError alloc] initWithDomain:@"domain"

                code:1

                userInfo:userInfoDict];

            *outError = error;

        }

        return NO;

    }

    else if( [*ioValue length] == 0 )

    {

        if (outError != NULL) {

            NSString *errorStr = @"length error";

            NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:errorStr

                forKey:NSLocalizedDescriptionKey];

            NSError __autoreleasing *error = [[NSError alloc] initWithDomain:@"domain"

                code:1

                userInfo:userInfoDict];

            *outError = error;

        }

        return NO;

    }

    else

    {

        return YES;

    }

}

When this runs, I see that the ioValue has 0 length and that it returns NO, but then my completion handler is never called. Any help would be great.

Is there something I am missing for how to handle saving errors with UIManagedDocument – particularly how to notify the calling code that an error happened while saving its information.

  • 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-14T06:06:56+00:00Added an answer on June 14, 2026 at 6:06 am

    I guess I need to implement handleError:(NSError *)error userInteractionPermitted:(BOOL)userInteractionPermitted in a subclass of the UIManagedDocument. I found that via this article – http://blog.stevex.net/2011/12/uimanageddocument-autosave-troubleshooting/

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

Sidebar

Related Questions

I have an iPhone app that uses core.data as its storage and a rest
Previously, I have an app that uses core data. I use same store url
I have an iphone app that uses Core Data to do storage. I have
I have an app that uses core data. The app is free for download
I am working on an app that uses Core Data as its backend for
We have an app that uses Core Data. In the next version I would
I have an app that fetches data from the internet and uses CoreData to
I have an Library-style app which uses Core Data to store its data. Currently
I have an app in the app store that uses Core Data to persist
I'm currently developing an app that uses Core Data. I'm using two stores/configurations, one

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.