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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:04:52+00:00 2026-06-06T01:04:52+00:00

I have a simple XCDataModel that contains one Entity with One Attribute. Essentially, I

  • 0

I have a simple XCDataModel that contains one Entity with One Attribute. Essentially, I am saving a series of Dates.

Now, I Know I am adding the NSDates properly because I run a fetch request after adding them and run through the results like so:

for (NSManagedObject *info in fetchedObjects) {
    NSLog(@"Name: %@", [info valueForKey:@"attribute"]);
}

And every additional NSDate is accounted for. Example from Log:

2012-06-19 12:40:38.531 Arts Days[47194:16103] Name: 2013-03-27 04:00:00 +0000
2012-06-19 12:40:38.531 Arts Days[47194:16103] Name: 2013-03-01 05:00:00 +0000
2012-06-19 12:40:38.532 Arts Days[47194:16103] Name: 2013-01-01 05:00:00 +0000

Now, when I try to delete an object from Core Data, it proves unsuccessful (by running the same fetch and running through the results again).

Here is the fetch:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

[fetchRequest setFetchBatchSize:366];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];

NSError *error = nil;

[fetchRequest setSortDescriptors:sortDescriptors];

NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

for (NSManagedObject *object in fetchedObjects) {
    if ([[object valueForKey:@"date"] isEqualToDate:date]) {
        [managedObjectContext deleteObject:object];
    }
}
if (![managedObjectContext save:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}

Also, the NSLog with Unresolved error contains nil nil…

Do you know what I am doing wrong?

  • 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-06T01:04:53+00:00Added an answer on June 6, 2026 at 1:04 am

    It appears you use two different NSManageObjectContext instances. self.managedObjectContext (an ivar) to set up your fetch request and perform the fetch, but a local instance to do the deleteObject: and save: operations. The local instance managedObjectContext is probably nil and not referring to the same object as the ivar.

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

Sidebar

Related Questions

i have a simple iphone project which contains a simple xcdatamodel that has a
I have simple query that loads data from two tables into GUI. I'm saving
I have simple php validation form that is halfway working. If you leave the
I have simple database - one table with 6 collumns. 3 of them i
I have simple win service, that executes few tasks periodically. How should I pass
i have simple QStandardItemModel that holds the date to show in QTreeview when i
I have simple aspx page that has a form and a input field in
I have simple multiple selection input <input multiple=true type=file name=image_name[] /> Now i would
i have simple url of image, i want to display that image in Bitmap
I have simple code that wants to read the state of network connection. I've

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.