My code is
// NSDecimalNumber *percentSpent = [distributionModel.spent decimalNumberByDividingBy:self.monthlySummaryModel.totalSpent];
// NSLog(@"percent:%@", percentSpent);
NSLog(@"spent:%@, totalSpent:%@", distributionModel.spent, self.monthlySummaryModel.totalSpent);
Where
@property (nonatomic, strong) NSDecimalNumber *spent;
@property (nonatomic) NSDecimalNumber *totalSpent;
Console log is this when the percentSpent
is commented out
2014-12-01 15:38:20.161 app-ios[15980:60b] spent:27.01, totalSpent:2077.01
2014-12-01 15:38:20.201 app-ios[15980:60b] spent:2000, totalSpent:2077.01
2014-12-01 15:38:20.251 app-ios[15980:60b] spent:40, totalSpent:2077.01
2014-12-01 15:38:20.292 app-ios[15980:60b] spent:10, totalSpent:2077.01
Error is this when I execute to calculate percentSpent
2014-12-01 15:35:44.843 app-ios[15963:60b] -[__NSCFNumber decimalNumberByDividingBy:]: unrecognized selector sent to instance 0x17d4f020
2014-12-01 15:35:44.851 app-ios[15963:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber decimalNumberByDividingBy:]: unrecognized selector sent to instance 0x17d4f020'
*** First throw call stack:
(0x2eaadf83 0x3925eccf 0x2eab1917 0x2eab0203 0x2e9ff768 0xac64b 0x313fd8f7 0x313a4c27 0x313a447d 0x312cad59 0x30f4862b 0x30f43e3b 0x30f43ccd 0x30f436df 0x30f434ef 0x30f3d21d 0x2ea79255 0x2ea76bf9 0x2ea76f3b 0x2e9e1ebf 0x2e9e1ca3 0x338e7663 0x3132e14d 0xa48cd 0x3976bab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
Signal: 6 (signal SIGABRT)
UPDATE
@interface MonthlySummaryModel : NSObject
@property (nonatomic) int year;
@property (nonatomic) int month;
@property (nonatomic) NSDecimalNumber *totalSpent;
@property (nonatomic, strong) NSArray *distributions;
and
@interface MonthlySummaryDistributionModel : NSObject
@property (nonatomic, strong) NSString *group;
@property (nonatomic, strong) NSDecimalNumber *spent;
- (MonthlySummaryDistributionModel *) initWithJson: (NSDictionary *) json;
@end
What is the issue here?