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

  • Home
  • SEARCH
  • 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 8494503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:18:59+00:00 2026-06-10T23:18:59+00:00

What is wrong with this code? I know this is a silly predicate. But

  • 0

What is wrong with this code?

I know this is a silly predicate. But it’s just to show that if this was working, it should be filter everything out, right?

Somehow, it’s not. I’m getting every Month object in my DB, when I should be getting none.

I guess this tells me that the problem might not be in the predicate?

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Month" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];

[fetchRequest setPredicate: [NSPredicate predicateWithFormat:@"1 == 0"]];

NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"month_" ascending:YES];

    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1, nil];
    [fetchRequest setSortDescriptors:sortDescriptors];
[fetchRequest setFetchBatchSize:20];

NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                    managedObjectContext:managedObjectContext
                                      sectionNameKeyPath:@"month_"
                                               cacheName:@"Root"];



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [[_fetchedResultsController sections] count];
}

What I actually wanted to do is,

[NSPredicate predicateWithFormat:@"year.year_ == %d", year]

And I also tried this,

[NSPredicate predicateWithFormat:@"month_ == %d", 1]

Just to see if it works. But nothing.

edit:

At this point, no matter what predicate I set, as long it’s a valid, well formatted predicate. It doesn’t complaint, and get’s me all objects. It’s just not filtering anything.

I’m pretty much using boiler plate code from Apple’s documentation.

Can anyone help me figure this out?

Thank you!

  • 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-10T23:19:00+00:00Added an answer on June 10, 2026 at 11:19 pm

    If using a cache, then the fetchRequest’s cache should be deleted, before being reused.

    Calling deleteCacheWithName: fixed the problem.

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

Sidebar

Related Questions

Ok, I don't know if this is possible, just something wrong with my code...
I do not know what is wrong with this code. alert shows that data
I don't know what's wrong with this code , this code compile successfully but
I don't know what wrong with this code but everytime when I run the
i dont know what is wrong with this code.. it will just don't work
I know this is going to sound silly but I can't find what's wrong.
I dont know whats wrong with this Code. The left hover works properly but
Please, help me. I dont know what is wrong with this code: import android.appwidget.AppWidgetProvider;
I don't know what is wrong with this code, it is a bug or
I don't know any PHP so another developer helped me out with this code.

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.