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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:12:25+00:00 2026-05-15T05:12:25+00:00

I am getting an exception when I try to get @sum on a column

  • 0

I am getting an exception when I try to get @sum on a column in iPhone Core-Data application.

My two models are following –

Task model:

@interface Task :  NSManagedObject
{

}

@property (nonatomic, retain) NSString * taskName;
@property (nonatomic, retain) NSSet* completion;

@end

@interface Task (CoreDataGeneratedAccessors)
- (void)addCompletionObject:(NSManagedObject *)value;
- (void)removeCompletionObject:(NSManagedObject *)value;
- (void)addCompletion:(NSSet *)value;
- (void)removeCompletion:(NSSet *)value;

@end

Completion model:

@interface Completion :  NSManagedObject
{
}

@property (nonatomic, retain) NSNumber * percentage;
@property (nonatomic, retain) NSDate * time;
@property (nonatomic, retain) Task * task;

@end

And here is the fetch:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
request.entity = [NSEntityDescription entityForName:@"Task" inManagedObjectContext:context];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"taskName" ascending:YES];
request.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSError *error;
NSArray *results = [context executeFetchRequest:request error:&error];
NSArray *parents = [results valueForKeyPath:@"taskName"];
NSArray *children = [results valueForKeyPath:@"completion.@sum.percentage"];
NSLog(@"%@ %@", parents, children);
[request release];
[sortDescriptor release];

The exception is thrown at the fourth line from bottom. The thrown exception is:

*** -[NSCFSet decimalValue]: unrecognized selector sent to instance 0x3b25a30
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFSet decimalValue]: unrecognized selector sent to instance 0x3b25a30'

I would very much appreciate any kind of help.
Thanks.

Edit: I am on snow leopard 10.6.3 and SDK 3.1.3.

  • 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-15T05:12:25+00:00Added an answer on May 15, 2026 at 5:12 am

    If you want to calculate the total completion percentage sum of each task you could implement a getter for “completionSum” in the task class

    // interface (Task.h)
    @property (nonatomic, readonly) NSNumber* completionSum;    
    
    // implementation (Task.m)
    -(NSNumber*) completionSum
    {
        return [self valueForKeyPath:@"completion.@sum.percentage"];
    }
    

    Calculating using @sum is slow and this solution is not KVO compliant.
    If you need any of this you should consider implementing a solution using KVO.

    I already postet a link to an open source solution to this problem (http://qr.cx/FVi)

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

Sidebar

Related Questions

I am getting the following exception when i try to use the fetchall method
When ever I try to launch my eclipse I am getting the following exception
I'm getting the following exception when I try to run my HQL query: java.util.concurrent.ExecutionException:
I keep getting this exception (in the title) whenever I try to get the
I'm getting the following exception when I try to run up my Winforms app
I'm getting an Ambiguous match found exception in NHibernate when I try to get
I'm getting an error [Exception: SyntaxError: Unexpected token :] when I try to evaluate
I'm getting an 'UnauthorizedAccesExpection - Invalid cross-thread access' exception when I try to raise
On my Arch Linux, Eclipse with Google Window Builder/SWT application, I am getting Exception
I'm passing some data between two activities but I'm getting a NullPointerException where 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.