FROM : Clayton Leitch
DATE : Sun Jun 22 23:26:22 2008
See code below. Get a error of “EXC_BAD_ACCESS” when I make entries
in the GUI. Code used to work with no problems. It appears that it
is doing an illegal substraction, which I think means the objects are
not being initialized with a value of 0. At least that is my guess.
#import "MonthlyReport.h"
@implementation MonthlyReport
+ (void)initialize
{
if (self == [MonthlyReport class])
{
NSArray *keys = [NSArray arrayWithObjects: @"reportCumActualCost",
@"reportActualCost", @"reportPredictedCost",
@"reportCumPredictedCost", @"reportCumlativeInvoiceTotal",
@"reportMonthlyInvoiceAmount", nil];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"reportCumDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"reportCurrentDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportPercentDifferenceMonth"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportPercentDifferenceCum"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportInvoiceMonthlyDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportInvoiceCumlativeDifference"];
}
}
//Calculate differences
- (NSDecimalNumber *)reportCurrentDifference;
{
return [[self valueForKey:@"reportActualCost"]
decimalNumberBySubtracting: [self valueForKey:@"reportPredictedCost"]];
}
- (NSDecimalNumber *)reportCumDifference;
{
return [[self valueForKey:@"reportCumActualCost"]
decimalNumberBySubtracting: [self
valueForKey:@"reportCumPredictedCost"]];
}
- (NSDecimalNumber *)reportInvoiceMonthlyDifference;
{
return [[self valueForKey:@"reportMonthlyInvoiceAmount"]
decimalNumberBySubtracting:[self valueForKey:@"reportActualCost"]];
}
- (NSDecimalNumber *)reportInvoiceCumlativeDifference;
{
return [[self valueForKey:@"reportCumlativeInvoiceTotal"]
decimalNumberBySubtracting:[self valueForKey:@"reportCumActualCost"]];
}
//Calculate percents
- (NSDecimalNumber *)reportPercentDifferenceMonth;
{
return [[[self valueForKey:@"reportCurrentDifference"]
decimalNumberByDividingBy: [self valueForKey:@"reportPredictedCost"]]
decimalNumberByMultiplyingByPowerOf10: (short)2];
}
- (NSDecimalNumber *)reportPercentDifferenceCum;
{
return [[[self valueForKey:@"reportCumDifference"]
decimalNumberByDividingBy: [self
valueForKey:@"reportCumPredictedCost"]]
decimalNumberByMultiplyingByPowerOf10: (short)2];
}
@end
DATE : Sun Jun 22 23:26:22 2008
See code below. Get a error of “EXC_BAD_ACCESS” when I make entries
in the GUI. Code used to work with no problems. It appears that it
is doing an illegal substraction, which I think means the objects are
not being initialized with a value of 0. At least that is my guess.
#import "MonthlyReport.h"
@implementation MonthlyReport
+ (void)initialize
{
if (self == [MonthlyReport class])
{
NSArray *keys = [NSArray arrayWithObjects: @"reportCumActualCost",
@"reportActualCost", @"reportPredictedCost",
@"reportCumPredictedCost", @"reportCumlativeInvoiceTotal",
@"reportMonthlyInvoiceAmount", nil];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"reportCumDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"reportCurrentDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportPercentDifferenceMonth"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportPercentDifferenceCum"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportInvoiceMonthlyDifference"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey
:@"reportInvoiceCumlativeDifference"];
}
}
//Calculate differences
- (NSDecimalNumber *)reportCurrentDifference;
{
return [[self valueForKey:@"reportActualCost"]
decimalNumberBySubtracting: [self valueForKey:@"reportPredictedCost"]];
}
- (NSDecimalNumber *)reportCumDifference;
{
return [[self valueForKey:@"reportCumActualCost"]
decimalNumberBySubtracting: [self
valueForKey:@"reportCumPredictedCost"]];
}
- (NSDecimalNumber *)reportInvoiceMonthlyDifference;
{
return [[self valueForKey:@"reportMonthlyInvoiceAmount"]
decimalNumberBySubtracting:[self valueForKey:@"reportActualCost"]];
}
- (NSDecimalNumber *)reportInvoiceCumlativeDifference;
{
return [[self valueForKey:@"reportCumlativeInvoiceTotal"]
decimalNumberBySubtracting:[self valueForKey:@"reportCumActualCost"]];
}
//Calculate percents
- (NSDecimalNumber *)reportPercentDifferenceMonth;
{
return [[[self valueForKey:@"reportCurrentDifference"]
decimalNumberByDividingBy: [self valueForKey:@"reportPredictedCost"]]
decimalNumberByMultiplyingByPowerOf10: (short)2];
}
- (NSDecimalNumber *)reportPercentDifferenceCum;
{
return [[[self valueForKey:@"reportCumDifference"]
decimalNumberByDividingBy: [self
valueForKey:@"reportCumPredictedCost"]]
decimalNumberByMultiplyingByPowerOf10: (short)2];
}
@end
| Related mails | Author | Date |
|---|---|---|
| Clayton Leitch | Jun 22, 23:26 | |
| Jean-Daniel Dupas | Jun 22, 23:43 | |
| Clayton Leitch | Jun 23, 00:38 | |
| Jason Coco | Jun 23, 00:43 | |
| Clayton Leitch | Jun 23, 01:08 | |
| Jason Coco | Jun 23, 02:19 | |
| Clayton Leitch | Jun 23, 03:04 | |
| Jens Alfke | Jun 23, 05:50 |






Cocoa mail archive

