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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:12:57+00:00 2026-05-25T11:12:57+00:00

Apologies if this has been answered before but I can’t find a reference. I

  • 0

Apologies if this has been answered before but I can’t find a reference. I am trying Cocoa / obj-c for the first time. I am trying to knock up an app which will sync with a remote backup system via http (a la s3) and am stumbling around some fundamental core data issues.

I have created an entity and can invoke this without issues. The problem arrives when I call save on NSManagedObjectContext.

I am not going to include all methods involved in invoking the object context / model as the log output should (I think) verify that it is working as expected.

Best described with code and appropriate log entries.


*First, for illustration, I am invoking the managed object: *

- (NSManagedObjectModel *)managedObjectModel {

    if (managedObjectModel != nil) {
        return managedObjectModel;
    }

    managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];    
    NSLog(@"The managed object model is defined as follows:\n%@",     managedObjectModel);
    return managedObjectModel;
}

And the log output from the above NSLog:

2011-09-06 14:31:38.322 TryAgain[18885:a0f] The managed object model is defined as follows:
(<NSManagedObjectModel: 0x2000e2b00>) isEditable 1, entities {
        BackupItinerary = "(<NSEntityDescription: 0x20020e9e0>) name BackupItinerary, managedObjectClassName NSManagedObject, renamingIdentifier 
            BackupItinerary, isAbstract 0, superentity name (null), properties {\n    \"file_url\" = \"(<NSAttributeDescription: 0x2000faec0>), name
            file_url, isOptional 0, isTransient 0, entity BackupItinerary, renamingIdentifier file_url, validation predicates (\\n), warnings (\\n),
            versionHashModifier (null), attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n    \"last_sync_date\" =
            \"(<NSAttributeDescription: 0x2000faf60>), name last_sync_date, isOptional 1, isTransient 0, entity BackupItinerary, renamingIdentifier
            last_sync_date, validation predicates (\\n), warnings (\\n), versionHashModifier (null), attributeType 900 , attributeValueClassName
            NSDate, defaultValue (null)\";\n}, subentities {\n}, userInfo {\n}, versionHashModifier (null)";
}, fetch request templates {
}

This looks so have been successful. No exceptions thrown, or warnings.

Now, the actual problem arrives when I call save on the object context. I have a NSOpenPanel which allows for picking dir / files to backup (all hooked up and working fine). Upon the user selecting a dir/file I want to set the value, so I:

NSArray *paths = [panel URLs];
NSURL *filePath = [paths objectAtIndex:0];
[directories addObject:filePath];
[directories setArray:[[NSSet setWithArray: directories] allObjects]];  
NSEntityDescription *BackupItineraryEntity = [[self.managedObjectModel  entitiesByName] objectForKey:@"BackupItinerary"];
NSManagedObject* BackupItinerary = [[NSManagedObject alloc]
                    initWithEntity:BackupItineraryEntity
    insertIntoManagedObjectContext:self.managedObjectContext];
[BackupItinerary setValue:[filePath absoluteString] forKey:@"file_url"];
NSLog(@"entity:\n%@", BackupItinerary);

And the call to NSLog says (having selected /Users/rick/selenium2-webdriver/):

2011-09-06 14:31:38.328 TryAgain[18885:a0f] entity:
<NSManagedObject: 0x200216c80> (entity: BackupItinerary; id: 0x200090860 <x-coredata:///BackupItinerary/t0C005B39-D185-454B-B364-31314EEB10F02> ;     
        data: {
            "file_url" = "file://localhost/Users/rick/selenium2-webdriver/";
            "last_sync_date" = nil;
        })

So, the file_url seems to be populated then, yes? But when I:

NSError *error;
if (![[self managedObjectContext] save:&error]) {
    NSLog(@"Unresolved error %@, %@, %@", error, [error userInfo],[error localizedDescription]);
}

The log says:

2011-09-06 14:31:38.330 TryAgain[18885:a0f] Unresolved error Error Domain=NSCocoaErrorDomain Code=1570 UserInfo=0x2000cc4e0 "file_url is a required  
value.", {
    NSLocalizedDescription = "file_url is a required value.";
    NSValidationErrorKey = "file_url";
    NSValidationErrorObject = "<NSManagedObject: 0x20020f660> (entity: BackupItinerary; id: 0x20008faa0 <x-coredata:///BackupItinerary/t0C005B39
            D185-454B-B364-31314EEB10F03> ; data: {\n    \"file_url\" = nil;\n    \"last_sync_date\" = nil;\n})";
}, file_url is a required value.

So basically:

I can, it seems (?), invoke the an entity and set a value on it, but when it comes to saving it the values is not set. The above code is executed inline and I am using garbage collection.

Feels like a total newb school boy error issue but for the life of me I can’t see what I am missing having gone over the docs, highlevel tutorials and example code.

Pointers appreciated!

  • 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-25T11:12:57+00:00Added an answer on May 25, 2026 at 11:12 am

    You are looking at two different managed object instances. The instance that has its file_url property set is <NSManagedObject: 0x200216c80> while the one that reports the error is <NSManagedObject: 0x20020f660>.

    Somewhere, you are inserting an instance but not giving it a file_url value. In the code given, it might happen if the user selects cancel in the NSOpenPanel.

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

Sidebar

Related Questions

Apologies if this has been answered before, but I find it very difficult to
I apologise if this has been asked before but I can't find the info
Apologies if this has been answered before (I couldn't find the answer when I
Apologies if this has been asked before (I couldn't find the answer anywhere), but
Apologies if this has been answered before. I've been trying to construct an XPath
Apologies if this has been answered elsewhere, but I have yet to find a
(Apologies if this has been asked before - I can't believe it hasn't, but
My apologies if this has been answered before or is obvious...did some searching here
Apologies if this has been answered already, but I'm going through the posts here
First off, I apologize if this has been asked before. I can't seem to

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.