title: Pass Array to NSObject Class
body: <p>I'm new to iphone app development and I'm stuck on this problem I'm having with the app I'm trying to develop.</p>
  
  <p>I have a datacontroller for populating a tableview. I created it using this tutorial:
  <a href="http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/SecondiOSAppTutorial/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011318-CH1-SW1" rel="nofollow">About Creating Your Second iOS App</a></p>
  
  <p>I'm trying to pass an array from one of my viewcontrollers that was created from a JSON response.</p>
  
  <p>Here is some code from my viewcontroller.h that needs to pass the array:</p>
  
  <pre><code>@interface ViewController : UIViewController
  
  @property (nonatomic, retain) DataController *Data;
  @property (nonatomic, retain) NSMutableArray *array;
  @end
  </code></pre>
  
  <p>viewcontroller.m:</p>
  
  <pre><code>  #import "DataController.h"
      [Data setMasterList: self.array];
  </code></pre>
  
  <p>DataController.h:</p>
  
  <pre><code>@interface DataController : NSObject
  
  @property (nonatomic, strong) NSMutableArray *masterList;
  
  - (void)setMasterList:(NSMutableArray *)newList;
  @end
  </code></pre>
  
  <p>DataController.m</p>
  
  <pre><code>#import "LoginViewController.h"
  
      - (void)setMasterList:(NSMutableArray *)newList {
            if (_masterList != newList) {
                _masterList = [newList mutableCopy];
            NSLog("List: %@", newList);
  
  
               }
            }
  </code></pre>
  
  <p>The NSLog message never shows up in the console and the array is nil.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>Here's the updated viewcontroller.m:</p>
  
  <pre><code>Data = [[DataController alloc] init];
  [Data setMasterList: self.array];
  </code></pre>
  
  <p>The datacontroller.m:</p>
  
  <pre><code>- (void)setMasterList:(NSMutableArray *)newList {
        if (_masterList != newList) {
            _masterList = [newList mutableCopy];
        NSLog("List: %@", self.masterList);
  
  
           }
  }
  
  - (NSUInteger)countOfList {
      NSLog("List: %@", self.masterList);
      return [self.masterList count];
  }
  </code></pre>
  
  <p>The first nslog inside setMasterList returns the correct array values, but the second nslog inside countOfList returns null. The list always returns null anywhere outside of setMasterList. Is it because I'm creating a new instance of the DataController? If so, how else could I pass the array to the datacontroller.</p>