title: Objective-C, class abstraction and accessing those variables
body: <p>I have a lot of experience with java and c++ development, so classes and abstracting data is pretty easy for me. I only started objective C a short time ago, and i was mostly working with in class globals, and everything was progressing smoothly. I just decided to abstract a large portion of my code in an effort to make it less spaghetti code, and i hit a problem that i haven't been able to overcome since Saturday.</p>
  
  <p>Outline:</p>
  
  <p>I am making a playing card game. I recently abstracted the card data into a class containing 3 variables; (int)i_cardValue, (int)i_cardSuit, and (UIImage *)uii_cardImage. I create a card by calling</p>
  
  <pre><code>-(PlayingCard *)initWithValue:(int)i_initValue suit:(int)i_initSuit image:(UIIMage*)uii_initImage {
  
       [self setCardValue:i_initValue];
  
       [self setCardSuit:i_initSuit];
  
       [self setCardImage:i_initImage];
  
       return self;
  
  }
  </code></pre>
  
  <p>I also abstracted the engine part (basically deck functions, such as shuffle and deck managment). The deck is a mutable array, and i have an init deck function.</p>
  
  <pre><code>NSMutableArray *nsma_deck;
  -(void)initDeck {
       nsma_deck = [[NSMutableArray alloc] initWithCapacity:52];
  }
  </code></pre>
  
  <p>Now, in my view controller, i make a call to initDeck, then i add items to the deck with a line such as</p>
  
  <pre><code>[pce_Engine initDeck];
  [[pce_Engine nsma_deck] addObject:[[PlayingCard alloc] initWithValue:13 suit:2 image:[UIImage imageNamed:@"2C.png"]]];
  </code></pre>
  
  <p>pce_Engine is a variable of type PlayingCardEngine. I put NSLog lines into the initDeck, and they do not display in console when i run my program. Are they not being called, so the array isnt getting alloced, and thus i cant add stuff to the array? I thought i did this all right, but either im doing it wrong or im missing something, because adding it to the view does not get it to display. Using an NSLog, the deck == nil, so i guess the problem is that i am not accessing the deck correctly and thus not adding values and only have empty variables everywhere :( . I tried looking at a lot of tutorials for objective c, but I haven't even found one that abstracts as far as I am going, so I haven't been able to find my problem.</p>
  
  <p>Can anyone point me in the right direction?</p>