title: objective C in Xcode - NSLog and access other class property
body: <p>I am a total newbie in Objective-C and Xcode (new to programming as well). I am trying to build a simple card game so I created a <code>Cards</code> class with properties and instance methods and imported its header file into "Viewcontroller.m".</p>
  
  <p>However, I do not understand two things:</p>
  
  <ol>
  <li><p>Why the <code>NSLog</code> in the "Cards.m" is not displaying in the console as I compile. But <code>NSLog</code> in "Viewcontroller.m" displays.</p></li>
  <li><p>Seems I can not call the <code>Cards</code> class (<code>NSMutableArray</code>) property. Even I initialized it without error in "Cards.m", in "Viewcontroller.m", the array is still empty.  </p></li>
  </ol>
  
  <p>Very appreciate your helps because I am very struggling!</p>
  
  <p>Cards.h:</p>
  
  <pre><code>@interface Cards : NSObject
  
  @property (strong, nonatomic) NSMutableArray* contents;
  
  -(void)makeContents;
  
  @end
  </code></pre>
  
  <p>Cards.m:</p>
  
  <pre><code>#import "Cards.h"
  @interface Cards()
  
  @end
  
  @implementation Cards
  
  @synthesize contents;
  
  -(id)init{
      if(self==[super init]){
          contents = [[NSMutableArray alloc]initWithCapacity:53];
      }
  
      return self;
  }
  
  -(void) makeContents{
       NSArray* suits = @[@"♥︎",@"♠︎",@"♣︎",@"♦︎" ];
  
       NSArray* ranks = [[NSArray alloc]initWithObjects:@"A",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"J",@"Q",@"K", nil];
       for(NSString* suiting in suits){
          for(NSString* ranking in ranks){
              NSString* cards = [NSString stringWithFormat:@"%@ %@", ranking,suiting];
              [contents addObject:cards];
  
              NSLog(@"%@", contents);//not displaying in console
          }
      }
  }
  
  @end
  </code></pre>
  
  <p>ViewController.m:</p>
  
  <pre><code>#import "ViewController.h"
  #import "Cards.h"
  
  @interface ViewController ()
  
  @property (weak, nonatomic) IBOutlet UILabel *flipCount;
  @property (nonatomic) int numberOfFlip;
  
  @end
  
  @implementation ViewController
  
  -(void)viewDidLoad{
      Cards* cards = [[Cards alloc]init];
  
      NSLog(@"%@", cards.contents); //displaying in console, the contents is an empty array still? why??
  }
  
  - (IBAction)flipCard:(UIButton *)sender {
  }
  
  @end
  </code></pre>