home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright (c) 1996, NeXT Software, Inc.
- All rights reserved.
-
- You may freely copy, distribute and reuse the code in this example.
- NeXT disclaims any warranty of any kind, expressed or implied,
- as to its fitness for any particular use.
- */
- #import <BusinessLogic/NSObjectAdditions.h>
- #import <EOControl/EOControl.h>
-
- @implementation NSObject(NSObjectAdditions)
-
- - (NSString *)className
- {
- return NSStringFromClass([self class]);
- }
-
- @end
-
- @implementation NSArray(NSDecimalNumberAdditions)
-
- - (NSDecimalNumber *)sumArrayWithKey:(NSString *)key
- {
- NSDecimal result = [[NSDecimalNumber zero] decimalValue];
- int i = [self count];
-
- while( i-- ) {
- NSDecimalNumber *n = [[self objectAtIndex:i] valueForKeyPath:key];
-
- if(n) {
- NSDecimal num;
- num = [n decimalValue];
- (void)NSDecimalAdd(&result, &result, &num, NSRoundBankers);
- }
- }
- return [NSDecimalNumber decimalNumberWithDecimal:result];
- }
-
- @end
-
-