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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:54:13+00:00 2026-05-30T08:54:13+00:00

I seem to be getting an error I can’t really understand. Hopefully this doesn’t

  • 0

I seem to be getting an error I can’t really understand. Hopefully this doesn’t get too confusing and longwinded, but as I can’t seem to find any answers in my searches, I think it might be necessary. In my program, I have several entities:

ItemSold
Invoice
Customer

Customer‘s can have many Invoices, Invoices can have many ItemSolds.

In my Interface Builder, I have three tables. One table represents customers, another represents invoices, and the last one represents itemsolds in that invoice.
So as you select a customer, their invoices show up in the invoice table. Once you click a invoice, the items on that invoice show up in the last table.

I seem to be getting the error when I select on a table. Interestingly, in another view, I can do this fine (when I’m trying to sort Items based on their relationship to Type). However I can’t get it to work here. This is my fetch to get the items that should be stored:

if (managedObjectContext == nil) 
{ 
    managedObjectContext = [(HistoryController *)[[NSApplication sharedApplication] delegate] managedObjectContext]; 
}
NSError *error = nil;

// fetch all customers
NSFetchRequest *fetchRequest2 = [[NSFetchRequest alloc] init];
NSEntityDescription *entity2 = [NSEntityDescription entityForName:@"Customer"
                                           inManagedObjectContext:managedObjectContext];
[fetchRequest2 setEntity:entity2];
fetchedCustomers = [managedObjectContext executeFetchRequest:fetchRequest2 error:&error];
if (fetchedCustomers == nil) {
    NSLog(@"ERROR");
}
[fetchRequest2 release];
// end of customer fetch

// fetch all invoices
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Invoice"
                                          inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];

NSLog(@"A");
if ([customerTable selectedRow] >= 0)
{
    NSLog(@"B");

    int index = (int)[customerTable selectedRow];

    NSLog(@"%@", index);
    NSString *customerString = [[fetchedCustomers objectAtIndex:(index)] valueForKey:@"CustomerNumber"];
    NSNumber *customerNumber = [NSNumber numberWithInt:([customerString intValue])];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"customer.CustomerNumber like %@", customerNumber];
    [fetchRequest setPredicate:predicate];
}

fetchedInvoices = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (fetchedInvoices == nil) {
    NSLog(@"ERROR");
}
[fetchRequest release];
// end of invoice fetch

// fetch specific invoice
NSFetchRequest *fetchRequest3 = [[NSFetchRequest alloc] init];
NSEntityDescription *entity3 = [NSEntityDescription entityForName:@"ItemSold"
                                           inManagedObjectContext:managedObjectContext];
[fetchRequest3 setEntity:entity3];

if ([invoicesListTable selectedRow] >= 0)
{

    NSLog(@"C");
    int index = (int)[invoicesListTable selectedRow];

    NSLog(@"%i", (int)[invoicesListTable selectedRow]);
    NSLog(@"%i", index);
    NSString *invoiceString = [[fetchedInvoices objectAtIndex:(index)] 
                                valueForKey:@"InvoiceNumber"];
    NSNumber *invoiceNumber = [NSNumber numberWithInt:([invoiceString intValue])];
    NSPredicate *predicate3 = [NSPredicate predicateWithFormat:@"invoice.InvoiceNumber like %@", invoiceNumber];
    [fetchRequest3 setPredicate:predicate3];
}

NSLog(@"D");

fetchedObjects = [managedObjectContext executeFetchRequest:fetchRequest3 error:&error];
if (fetchedObjects == nil)
{
    NSLog(@"ERROR");
}
[fetchRequest3 release];

[invoiceTable reloadData];
NSLog(@"D2");

}

If I execute, and click on a row, this is what I get:

2012-02-13 16:42:35.326 InventoryProgram[7056:707] A

2012-02-13 16:42:35.327 InventoryProgram[7056:707] C

2012-02-13 16:42:35.327 InventoryProgram[7056:707] 0

2012-02-13 16:42:35.328 InventoryProgram[7056:707] 0

2012-02-13 16:42:35.328 InventoryProgram[7056:707] D

2012-02-13 16:42:35.329 InventoryProgram[7056:707] Can't create a regex expression from object 2.

I’m showing the output of the letters just to show where control follows. It follows as I select a row, outputs the correct row number (0), and in fact makes it past where I thought the problem was. Outputting the letter D, it passes the NSPredicate area, which is what I thought the regex problem was coming from. I’m assuming now that it gets to the executeFetchRequest, and encounters the problem of the NSPredicate assigned to it.

Does anyone have any ideas/anything at all to point me in the right direction here? I can’t wrap my mind around what the problem is. I really hope there wasn’t too much code here, I’m just trying to give all the information I can.

  • 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-30T08:54:14+00:00Added an answer on May 30, 2026 at 8:54 am

    Replace:

    NSString *invoiceString = [[fetchedInvoices objectAtIndex:(index)] 
                                valueForKey:@"InvoiceNumber"];
    NSNumber *invoiceNumber = [NSNumber numberWithInt:([invoiceString intValue])];
    NSPredicate *predicate3 = [NSPredicate predicateWithFormat:@"invoice.InvoiceNumber like %@", invoiceNumber];
    

    With:

    NSString *invoiceString = [[fetchedInvoices objectAtIndex:(index)] 
                                    valueForKey:@"InvoiceNumber"];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"invoice.InvoiceNumber = %@", invoiceString];
    

    Solves the problem.

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

Sidebar

Related Questions

This is a really nebulous error that I can't seem to get a lot
I can't seem to get this program to compile. I keep getting the error:
This may seem like a simple question but i am getting an error when
This might seem ridiculously simple, but I've been getting all kinds of error depending
This is going to seem like a really silly question but I can't figure
First python script and I'm getting an error I can't seem to get around
I am getting this php error and I can't seem to fix it. Fatal
Seem to be getting an error but can't figure out how to drill down
I think this is a really, really simple question but I can't seem to
I'm getting the following error message and I can't seem to figure out the

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.