title: XCode Passing NSMutableArray from Different Classes
body: <p>I have 2 classes. A and B. Inside ClassA I have a method which retrieve JSON data and adds into an array. I want to access this array from ClassB. How can I achieve it?</p>
  
  <pre><code>ClassA.h
  - (void)viewDidLoad
  {
  //initialise arrayPlaces and arrayWeather
  [super viewDidLoad];
  
  dispatch_async(queue, ^{
  NSData* data = [NSData dataWithContentsOfURL: 
                      serverURL];
                      [self performSelectorOnMainThread:@selector(fetchedData:) 
                      withObject:data waitUntilDone:YES];
  });
  }
  
  - (void)fetchedData:(NSData *)responseData {
  
  //parse out the json data
  NSError *error;
  NSMutableArray *tempArray = [[NSMutableArray alloc] init];
  tempArray = [NSJSONSerialization 
               JSONObjectWithData:responseData //1
               options:kNilOptions 
               error:&amp;error];
  
  //declare arrayPlaces
  arrayToPass = [[NSMutableArray alloc] init];
  
  //...codes to add array here using a loop...
  [arrayToPass addObject:tempString];
  }
  </code></pre>
  
  <p>In ClassB, I have a tableView which i want to get all the array from ClassA. How can I achieve this?</p>
  
  <pre><code>ClassA *cA = [[ClassA alloc]init];
  ClassA.view;
  arrayReceived = ClassA.arrayToPass;
  </code></pre>
  
  <p>The above doesn't seem to work when implemented in ClassB.</p>
  
  <pre><code>ClassB *cB = [[ClassB alloc] init];
  [cB setArrayReceived:arrayToPass];
  </code></pre>
  
  <p>Neither does this work when implemented in ClassA after this portion of the code.
  "//...codes to add array here using a loop...
  [arrayToPass addObject:tempString];</p>
  
  <p>Please help!! Thanks!</p>