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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:34:23+00:00 2026-05-21T09:34:23+00:00

I am working on a simple comparison of two lists to see which items

  • 0

I am working on a simple comparison of two lists to see which items in an “evaluation” list are contained in a larger “target” list. I am getting the data on-the-fly- by parsing two CSV files and storing everything as strings. I successfully import the data into the data store and I can get a list of entities no problem

The problem comes when I actually do a search. Essentially, I am looking for short ISBNs in the form of 1234 from the evaluation list in the target list, which are in the form of 1234-5. The predicate I am using is I am using the CONTAINS comparison in the form of [NSString stringWithFormat:@"%@ CONTAINS %@", kOC_Target_PrintBookCode, evalIsbn]

The error I get is the following (grabbed by my NSLog)

NSInvalidArgumentException: Can't look for value (1494) in string (49885); value is not a string

I get the impression that even though the ISBN is being read from a NSString and the Core Data store has the data point spec’d as a String, that Core Data is still doing something in the background with the value for whatever reason it sees fit. Any ideas?


Here is the relevant process logic (though I use that term dubiously) code. Unless otherwise noted in the code, all values being manipulated and/or stored are NSString:

NSArray *evalBooks = [self getEntitiesByName:kOC_EntityName_EvalBook 
                             usingPredicateValue:[NSString stringWithFormat:@"%@ > \"\"", kOC_Eval_Bookcode] 
                       withSubstitutionVariables:nil 
                                         inModel:[self managedObjectModel]
                                      andContext:[self managedObjectContext] 
                                 sortByAttribute:nil];

    if ( ( !evalBooks ) || ( [evalBooks count] == 0 ) ) {
        // we have problem
        NSLog(@"( !evalBooks ) || ( [evalBooks count] == 0 )");
        return;
    }

    [evalBooks retain];

    int firstEvalBook = 0;
    int thisEvalBook = firstEvalBook;
    int lastEvalBook = [evalBooks count]; NSLog(@"lastEvalBook: %i", lastEvalBook);
    for (thisEvalBook = firstEvalBook; thisEvalBook < lastEvalBook; thisEvalBook++) {

        NSManagedObject *evalBook = [[evalBooks objectAtIndex:thisEvalBook] retain];

        NSString *rawIsbn = [[evalBook valueForKey:kOC_Eval_Bookcode] retain];
        NSString *isbnRoot = [[self getIsbnRootFromIsbn:rawIsbn] retain];
        // this is a custom method I created and use elsewhere without any issues.
        NSArray *foundBooks = [self getEntitiesByName:kOC_EntityName_TargetBook 
                                   usingPredicateValue:[NSString stringWithFormat:@"%@ CONTAINS %@", kOC_Target_PrintBookCode, isbnRoot]
                             withSubstitutionVariables:nil 
                                               inModel:[self managedObjectModel] 
                                            andContext:[self managedObjectContext] 
                                       sortByAttribute:kOC_Target_PrintBookCode];

        if ( foundBooks != nil ) {

            [foundBooks retain];
            NSLog(@"foundBooks: %lu", [foundBooks count]);

        } else {

        }
  • 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-21T09:34:24+00:00Added an answer on May 21, 2026 at 9:34 am

    If you’re building your predicate as an NSString, I believe

    [NSString stringWithFormat:@"%@ CONTAINS %@", kOC_Target_PrintBookCode, isbnRoot]
    

    should actually be

    [NSString stringWithFormat:@"%@ CONTAINS '%@'", kOC_Target_PrintBookCode, isbnRoot]
    

    It seems that you’re confusing the way predicateWithFormat: works with the way stringWithFormat: works.

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

Sidebar

Related Questions

I am working in simple application in which I need to post data to
The simple working query, list the number of licenses for each license type: Query:
I am working on simple application which creates google calendar (under it's own account).
I have multiple ordered lists. Unfortunately, the order of the items isn't a simple
I am Working on simple login application in which user is first shown login
hi iam currently working in simple amimation app in which i implement following code
I am working on simple iphone application. where i am working on two views.
Working on a simple C program I'm stuck with an if test: int line_number
Working on a simple TimeTracker App. You start a timer, wait a certain time,
im working on a simple C++ HTTP server as a school project and I

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.