title: Trying to loop through an array and total up NSDecimalNumbers
body: <p>I have the following code:</p>
  
  <pre><code>- (NSDecimalNumber *)totalBudgetItems {
      NSEnumerator *e = [self.defaultBudgetItemsArray objectEnumerator];
      id object;
      while (object = [e nextObject]) {
          NSDecimalNumber *numberToAdd = [[NSDecimalNumber alloc] initWithDecimal:[[object objectForKey:@"actualValue"] decimalValue]];
          currentTotal = [currentTotal decimalNumberByAdding:numberToAdd];
          [numberToAdd release];
      }
      return currentTotal;
  }
  </code></pre>
  
  <p>It crashes on the line where I alloc numberToAdd. In the debugger, I open up "Locals", followed by "numberToAdd". "currentTotal" is in red with "invalid CFStringRef" in it. Otherwise I'm not sure what is happening. </p>
  
  <p>In my .h I have:</p>
  
  <pre><code>NSDecimalNumber *currentTotal;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@property (nonatomic, retain) NSDecimalNumber *currentTotal;
  </code></pre>
  
  <p>The console also says:</p>
  
  <pre><code>2010-10-06 13:32:07.018 App[9433:307] -[NSCFString objectForKey:]: unrecognized selector sent to instance 0x16c6f0
  2010-10-06 13:32:07.030 App[9433:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance 0x16c6f0'
  </code></pre>
  
  <p>Any thoughts?</p>
  
  <p>Thanks!</p>
  
  <p>-Max</p>