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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:56:12+00:00 2026-06-04T20:56:12+00:00

In Objective-C, using core data, I was fetching entities and they were returned as

  • 0

In Objective-C, using core data, I was fetching entities and they were returned as NSArrays. I realized that I was fetching too often and I could make use of the entity’s return values, for example: Customer entity has many Invoices, Invoices have many ItemSolds. Here is some code I’m using:

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

This is the simple fetch request, and fetchedCustomers is set as an NSArray property. I then use it’s functions :

self.fetchedInvoices = [[customerToView valueForKey:@"invoices"] allObjects];

This works, and I’m able to display invoice numbers and dates into a table properly. However I then go on to use :

self.fetchedObjects = [[fetchedInvoices valueForKey:@"itemsSold"] allObjects];

Later, when I try to add totals I do the following:

 double price = [[[fetchedObjects objectAtIndex:i] valueForKey:@"Price"] doubleValue];

And I get the following error:

-[__NSCFSet doubleValue]: unrecognized selector sent to instance 0x10228f730

Why is there an NSSet involved here at all? When I fetched the invoices and items using predicates, I didn’t have any problems, but it seemed really inefficient. I would much rather figure out what’s going wrong here. Any help would be appreciated, thanks.

Extra info:

Areas of interest:

@interface Invoice : NSManagedObject {
@private
}
@property (nonatomic, retain) NSSet *itemsSold;
@end

@interface Invoice (CoreDataGeneratedAccessors)

- (void)addItemsSoldObject:(ItemSold *)value;
- (void)removeItemsSoldObject:(ItemSold *)value;
- (void)addItemsSold:(NSSet *)values;
- (void)removeItemsSold:(NSSet *)values;

@end
  • 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-04T20:56:13+00:00Added an answer on June 4, 2026 at 8:56 pm

    I realized my error. I was sorting the fetchedCustomers into a specific “customerToView”. I did not do the same thing with my fetchedInvoices. So my solution as to add :

    NSManagedObject *invoiceToView = [fetchedInvoices objectAtIndex:(int)[invoicesTable selectedRow]];
    

    And use invoiceToView in the place of fetchedInvoices.

    Foolish error on my part!

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

Sidebar

Related Questions

I'm trying to make my first application using Objective C + Core Data, but
I'm using Objective-C Distributed Objects (DO) to share data from one application (that collects
I'm trying to implement the Strategy pattern using Core Data and Objective C. To
I am fetching a set of objects from a Core Data persistent store using
I understand Objective-C memory management but I'm using Core Graphics functionality such as CGRect,
Possible Duplicate: how to make phone call by using objective c? I am trying
I am using Core Data for my app and I have a model Reservation
I am using core data and am generating classes from my data model. I
I'm using OCMock to mock some Core Data objects. Previously, I had the properties
Per the Core Data Programming Guide: You can specify that an attribute is optional—that

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.