سؤال

I have an entity attribute in which are stored both numbers and empty field. I need the sum and the average values of this attributes values but doing @"@sum.attributeName" or @"@avg.attributeName" I get

Terminating app due to uncaught exception 'NSDecimalNumberOverflowException', reason: 'NSDecimalNumber overflow exception'

Thank's

هل كانت مفيدة؟

المحلول

I solved even if the Attributes are String Type as follows:

 NSArray *allValues = [array valueForKeyPath:@"@unionOfObjects.entityAttribute"];
NSMutableArray *allNumberValues = [[NSMutableArray alloc] init];


for (int i=0; i<valoriVotoEsame.count; i++) {

    if (            ![[allValues objectAtIndex:i] isEqual:@""])
    {
        [allNumberValues addObject:[allValues objectAtIndex:i]];


    }

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top