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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:54:29+00:00 2026-05-24T19:54:29+00:00

Getting this error with my fetch’s predicate 2011-08-13 13:49:12.405 Codes[16957:10d03] NSlog Array: code BETWEEN

  • 0

Getting this error with my fetch’s predicate

2011-08-13 13:49:12.405 Codes[16957:10d03] NSlog Array: code BETWEEN {"06", "07"} 
2011-08-13 13:49:12.407 Codes[16957:10d03] -[NSCFString constantValue]: unrecognized selector sent to instance 0x7464610 
2011-08-13 13:49:12.409 Codes[16957:10d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString constantValue]: unrecognized selector sent to instance 0x7464610'

NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@", [NSArray arrayWithObjects:self.predicateFilterStart, self.predicateFilterEnd, nil]];:

NSLog shows code BETWEEN {"06", "07"}

Model Class for NSManagedObject with property code:

@interface MedicalCode : NSManagedObject

@property (nonatomic, retain) NSString * code;
@property (nonatomic, retain) NSString * codeDescription;
@property (nonatomic, retain) NSString * name;

FRC method: (ICD9Procedure is subclass of MedicalCode)

- (NSFetchedResultsController *)fetchedResultsController
{
    if (__fetchedResultsController != nil)
    {
        return __fetchedResultsController;
    }

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

    NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"ANY code BEGINSWITH[c] %@", self.predicateFilter];
    [fetchRequest setPredicate:myPredicate];    

    [fetchRequest setFetchBatchSize:20];
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"code" ascending:YES];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    [aFetchedResultsController release];
    [fetchRequest release];
    [sortDescriptor release];
    [sortDescriptors release];

    NSError *error = nil;
    if (![self.fetchedResultsController performFetch:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    return __fetchedResultsController;
} 

EDIT:

All I need is a predicate that filters data.
I have a property of an entity called code that is in format like 55.534.
I’m trying to fetch all data in a range, for example 50-60.

  • 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-24T19:54:30+00:00Added an answer on May 24, 2026 at 7:54 pm

    Try:

    NSString *start = @"06";
    NSString *end = @"07";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@",
                          [NSArray arrayWithObjects: start, end, nil]];
    NSLog(@"%@", pred);
    

    That works for me:

    2011-08-13 23:45:52.019 PredicateTest[18493:707] ANY code BETWEEN {"06", "07"}
    

    so the error is probably in the properties.

    FWIW, constantValue is a method of NSExpression. Not sure if that helps you.


    I see you updated your code. Now it is very unclear where your error happened, since the code you orginally posted does not appear in the code you added, nor does it give additional info about the properties you are using.

    And you say the error does not appear in the code you originally posted. It happens in a different piece of code, which you posted now, but it is not clear to me how that relates to the original code.

    Update

    Apparently, from the discussion inthe comments, it turns out you need numbers, so do something like:

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@",
                          [NSArray arrayWithObjects: 
                            [NSNumber numberWithDouble: 50.0],
                            [NSNumber numberWithDouble: 60.0],
                            nil]];
    

    Final solution

    For those interested: the following apparently works.

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY code BETWEEN %@",
                          [NSArray arrayWithObjects: 
                            [NSExpression expressionForConstantValue: [NSNumber numberWithDouble: 50.0]],
                            [NSExpression expressionForConstantValue: [NSNumber numberWithDouble: 60.0]],
                            nil]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are getting this error after upgrading to NHibernate 2.1. [QueryException: Cannot simultaneously fetch
I'm getting an undefined index error in this code: function get_userdata() { global $db;
I am getting this error on the following code, and cant figure out why.
For the code below i am getting this error : JSON.parse: unexpected end of
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Anyone getting this error when using the new free chart controls MS bought from
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to
am getting this error when i open my site in internet explorer......... plz help

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.