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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:41:55+00:00 2026-05-25T20:41:55+00:00

when using an nspredicate ( a between predicate) i had an exception. there is

  • 0

when using an nspredicate ( a between predicate) i had an exception.

there is the code i used:

NSMutableArray *returnedArray=[[[NSMutableArray alloc]init] autorelease];
NSManagedObjectContext *context = [self managedObjectContext]; 
NSEntityDescription *objEntity = [NSEntityDescription entityForName:@"Note" inManagedObjectContext:context];



NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:objEntity];


NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"When" ascending:YES];   

NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];   
[fetchRequest setSortDescriptors:sortDescriptors];   
[sortDescriptor release]; 



NSPredicate *predicate1 = [NSPredicate predicateWithFormat:
                          @"self.Reunion==%@",reunion];
NSNumber *endOfEtape=[NSNumber numberWithInt:[etape.positionDepart intValue]+[etape.duree intValue]];
NSExpression *s1 = [ NSExpression expressionForConstantValue: etape.positionDepart ];
NSExpression *s2 = [ NSExpression expressionForConstantValue: endOfEtape ];
NSArray *limits = [ NSArray arrayWithObjects: s1, s2, nil ];
 NSPredicate *predicate2=[NSPredicate predicateWithFormat: @"self.When BETWEEN %@",limits];

NSPredicate *predicate=[NSCompoundPredicate andPredicateWithSubpredicates:
                                [NSArray arrayWithObjects:predicate1,predicate2,nil]];
[fetchRequest setPredicate:predicate];


NSArray *notes; 
notes=[context executeFetchRequest:fetchRequest error:nil];

[fetchRequest release];

and i had an ‘objc_exception_throw’ at the line on which i call “executeFetchRequest:” method.

I will be happy if you can help me.
Thanks.

  • 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-25T20:41:55+00:00Added an answer on May 25, 2026 at 8:41 pm

    Unfortunately, the BETWEEN operand is considered an aggregate function & these aren’t supported by CoreData.

    See Apple’s Documentation

    … consider the BETWEEN operator (NSBetweenPredicateOperatorType); its
    right hand side is a collection containing two elements. Using just
    the Mac OS X v10.4 API, these elements must be constants, as there is
    no way to populate them using variable expressions. On Mac OS X v10.4,
    it is not possible to create a predicate template to the effect of
    date between {$YESTERDAY, $TOMORROW}; instead you must create a new
    predicate each time.

    Aggregate expressions are not supported by Core Data.

    So you’ll need to use a predicate like:

    NSPredicate *predicate2 = [NSPredicate predicateWithFormat: 
    @"self.When >= %@ AND self.When <= %@", etape.positionDepart, endOfEtape];
    

    (assuming positionDepart and endOfEtape are of type NSString)

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

Sidebar

Related Questions

I'm building a NSPredicate using the code below for an iPhone app. The logging
I am presenting table view contents using NSFetchedResultsController which has a predicate: [NSPredicate predicateWithFormat:@visible
I'm building a carArray and want to filter the contents conditionally, using an NSPredicate
Can someone please help me with using Regex with NSPredicate? NSString *regex = @(?:[A-Za-z0-9]);
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I am using Core Data to develop an application, and I have used a
I'm using the following code and I'm getting an EXC_BAD_ACCESS when trying to get
I am using a predicate to find an object in core data. I can
I'm using the code below to Fetch a queried set of all rows using

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.