Need to find out why I get Cocoa error 256 . . .

  • Where can I find detail on the following error code?  Or, can someone
    point me to information on how to effectively debug a failure for a
    CoreData -[NSManagedObjectContext save] invocation?

    2009-04-13 10:17:28.625 SpecialOrders[4923:20b] Failed to save context
    with new data: Error Domain=NSCocoaErrorDomain Code=256
    UserInfo=0xf4b150 "Operation could not be completed. (Cocoa error 256.)"

    -Michael
  • When I change the persistent-store type from SQLite to Binary, my code
    works.  I'm able to save the Managed Object Context.  On the next run,
    my fetch works because there is not data in the persistent store.
    Anyone have any idea why the store type makes the difference?

    /**
      Returns the persistent store coordinator for the application.
      If the coordinator doesn't already exist, it is created and the
    application's store added to it.
      */
    - (NSPersistentStoreCoordinator*)persistentStoreCoordinator
    {
        if ( nil == persistentStoreCoordinator )
        {
    #if 0
            NSURL* storeUrl = [NSURL fileURLWithPath:[[self
    applicationDocumentsDirectory]
    stringByAppendingPathComponent:@"SpecialOrders.sqlite"]];
    #else
            NSURL* storeUrl = [NSURL fileURLWithPath:[[self
    applicationDocumentsDirectory]
    stringByAppendingPathComponent:@"SpecialOrders.bin"]];
    #endif

            NSError *error;
            persistentStoreCoordinator = [[NSPersistentStoreCoordinator
    alloc] initWithManagedObjectModel:[self managedObjectModel]];
    #if 0
            if ( ![persistentStoreCoordinator
    addPersistentStoreWithType:NSSQLiteStoreType

    configuration:nil URL:storeUrl

    options:nil error:&error] )
    #else
            if ( ![persistentStoreCoordinator
    addPersistentStoreWithType:NSBinaryStoreType

    configuration:nil URL:storeUrl

    options:nil error:&error] )
    #endif
            {
                // Handle error
                NSLog(@"Error adding persistent store to coordinator");
            }
        }
        return persistentStoreCoordinator;
    }

    >
    > #pragma mark -
    > #pragma mark AppController methods
    >
    > - (void)viewDidLoad
    > {
    > [super viewDidLoad];
    >
    > // Set up the edit and add buttons.
    > self.navigationItem.leftBarButtonItem = self.editButtonItem;
    >
    > UIBarButtonItem* addButton = [[UIBarButtonItem alloc]
    > initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self
    > action:@selector(insertNewObject)];
    > self.navigationItem.rightBarButtonItem = addButton;
    > [addButton release];
    >
    > NSError *error;
    >
    > if ( ![[self fetchedResultsController] performFetch:&error] )
    > {
    > // Handle the error...
    > NSLog(@"Failed to perform initial fetch for view");
    > }
    >
    > //
    > // If the fetch resulted in no records, create and save instances
    > of each of
    > // the model objects.
    > //
    > NSArray* fetchedObjects = [[self fetchedResultsController]
    > fetchedObjects];
    >
    > if ( (nil == fetchedObjects) || (0 == fetchedObjects.count) )
    > {
    > NSLog(@"Nothing returned from fetch; creating dummy objects");
    >
    > Language* language = [NSEntityDescription
    > insertNewObjectForEntityForName:@"Language"
    > inManagedObjectContext:self.managedObjectContext];
    > language.name = @"English";
    > language.symbol = @"EN";
    >
    > Publication* publication = [NSEntityDescription
    > insertNewObjectForEntityForName:@"Publication"
    > inManagedObjectContext:self.managedObjectContext];
    > publication.ID = [NSNumber numberWithInt:5334];
    > publication.languages = [NSSet setWithObject:language];
    > publication.name = @"Bible Teach";
    > publication.symbol = @"bh";
    >
    > language.publications = [NSSet setWithObject:publication];
    >
    > Publisher* publisher = [NSEntityDescription
    > insertNewObjectForEntityForName:@"Publisher"
    > inManagedObjectContext:self.managedObjectContext];
    > publisher.firstName = @"Michael";
    > publisher.lastName = @"Crawford";
    >
    > Request* request = [NSEntityDescription
    > insertNewObjectForEntityForName:@"Request"
    > inManagedObjectContext:self.managedObjectContext];
    > request.language    = language;
    > request.publication = publication;
    > request.publisher  = publisher;
    > request.timeStamp  = [NSDate date];
    >
    > publisher.requests = [NSSet setWithObject:request];
    > publication.requests = [NSSet setWithObject:request];
    >
    > Order* order = [NSEntityDescription
    > insertNewObjectForEntityForName:@"Order"
    > inManagedObjectContext:self.managedObjectContext];
    > order.ID = [NSNumber numberWithInt:1];
    > order.requests = [NSSet setWithObject:request];
    > order.timeStamp = [NSDate date];
    >
    > request.order = order;
    >
    > NSLog(@"language = %@", language);
    > NSLog(@"publication = %@", publication);
    > NSLog(@"publisher = %@", publisher);
    > NSLog(@"request = %@", request);
    > NSLog(@"order = %@", order);
    >
    > NSError* error;
    >
    > if ( ![[fetchedResultsController managedObjectContext]
    > save:&error] )
    > {
    > NSLog(@"Failed to save context with new data: %@", error);
    > }
    >
    > [self.tableView reloadData];
    > }
    > }

    -Michael
    ----------------------
    There are two ways of constructing a software design. One way is to
    make it so simple that there are obviously no deficiencies.
    And the other way is to make it so complicated that there are no
    obvious deficiencies.

    -- C.A.R. Hoare

    On Apr 13, 2009, at 10:25 AM, Michael A. Crawford wrote:

    > Where can I find detail on the following error code?  Or, can
    > someone point me to information on how to effectively debug a
    > failure for a CoreData -[NSManagedObjectContext save] invocation?
    >
    > 2009-04-13 10:17:28.625 SpecialOrders[4923:20b] Failed to save
    > context with new data: Error Domain=NSCocoaErrorDomain Code=256
    > UserInfo=0xf4b150 "Operation could not be completed. (Cocoa error
    > 256.)"
    >
    > -Michael
  • Hi Michael,

    You'll find the error defined in <Foundation/FoundationErrors.h>:
        NSFileReadUnknownError = 256,                          // Read
    error (reason unknown)

    —Jeremy

    On Mon, Apr 13, 2009 at 10:25 AM, Michael A. Crawford
    <michaelacrawford...> wrote:
    > Where can I find detail on the following error code?  Or, can someone point
    > me to information on how to effectively debug a failure for a CoreData
    > -[NSManagedObjectContext save] invocation?
    >
    > 2009-04-13 10:17:28.625 SpecialOrders[4923:20b] Failed to save context with
    > new data: Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0xf4b150
    > "Operation could not be completed. (Cocoa error 256.)"
    >
    > -Michael
    >
  • Or, in the docs

    search for it in Xcode's Documentation window

    On 13-Apr-09, at 9:32 PM, Jeremy W. Sherman wrote:

    > Hi Michael,
    >
    > You'll find the error defined in <Foundation/FoundationErrors.h>:
    > NSFileReadUnknownError = 256,                          // Read
    > error (reason unknown)
    >
    > —Jeremy
    >
    > On Mon, Apr 13, 2009 at 10:25 AM, Michael A. Crawford
    > <michaelacrawford...> wrote:
    >> Where can I find detail on the following error code?  Or, can
    >> someone point
    >> me to information on how to effectively debug a failure for a
    >> CoreData
    >> -[NSManagedObjectContext save] invocation?
    >>
    >> 2009-04-13 10:17:28.625 SpecialOrders[4923:20b] Failed to save
    >> context with
    >> new data: Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0xf4b150
    >> "Operation could not be completed. (Cocoa error 256.)"
    >>
    >> -Michael
    >>

previous month april 2009 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Go to today