title: Having trouble adding objects to NSMutableArray in Objective C
body: <p>I am using the iPhone SDK and have an issue doing something simple. I am trying to add an <strong>NSNumber</strong> object to an <strong>NSMutableArray</strong> instance variable. I tried adding NSNumber <strong>card</strong> to NSMutableArray <strong>viewedCardsArray</strong>, however without breaking, it does not get added to the array. Here is the code.</p>
  
  <pre><code>
  /////////////////////////////////////////////////////
  // Inside the header file Class.h
  @interface MyViewController : UIViewController {
     NSMutableArray *viewedCardsArray;
     //snip ...
  }
  @property (nonatomic, retain) NSMutableArray *viewedCardsArray;
  @end
  
  /////////////////////////////////////////////////////
  // Inside the methods file Class.m
  #import "StudyViewController.h"
  
  @implementation StudyViewController
  @synthesize viewedCardsArray
    //snip ...
  
  - (IBAction)doShowCard {
     //snip ...
     NSNumber *cardIdObject = [[NSNumber alloc] initWithInt:(int)[self.currentCard cardId]];
     [viewedCardsArray addObject: cardIdObject];
     [cardIdObject release];
  }
  </code></pre>
  
  <p>So this code executes, and does not seem to leak (according to the Leaks performance tool). However when stepping through the code, at no point does <strong>CardIdObject</strong> appear in <strong>viewedCardsArray</strong>.</p>
  
  <p>Looking through SO, I know these basic questions are pretty common to ObjC newbies (like me) so apologies in advance!</p>