title: Passing NSMutableArray from one View Controller to a function in another
body: <p>I've read up on couple of questions here on SO about passing data between two View Controllers and seen different ways suggested of doing it. My problem is as follows:</p>
  
  <p>I have a view controller (lets call it a "A") that has a searchbar in a toolbar. Nothing else. Then I have another view controller ("B") that is responsible for displaying a popover view when the user presses the search button on the keyboard when searching in the searchbar.
  This all works. The user enters text, presses the search button, the popover is shown. Great.</p>
  
  <p>Now I have yet to display any search results in the popover tableview and am trying to pass a  <code>NSMutableArray</code> to a function in B as an argument:</p>
  
  <p>in B.h:</p>
  
  <pre><code>@property (nonatomic, retain) NSMutableArray *searchResults;
  </code></pre>
  
  <p>in B.m:</p>
  
  <pre><code>    @synthesize searchResults;
  
       -(void)setSearchResults:(NSMutableArray *)resultArray{
           [self.searchResults removeAllObjects];
           [self.searchResults addObjectsFromArray:resultArray];
       }
  </code></pre>
  
  <p>in A.h:</p>
  
  <pre><code>#import "B.h"
  @property(nonatomic, retain) B *viewControllerObjectB;
  </code></pre>
  
  <p>in A.m:</p>
  
  <pre><code>@synthesize viewControllerObjectB;
  
   //The searchResultsArray is passed on from another function
  -(void)communicateWithB:(NSMutableArray *)searchResultsArray{
  
      //I initialize the viewControllerObjectB in here
  
      NSMutableArray *temp = [[NSMutableArray alloc] initWithArray:searchResultsArray];
      [viewControllerObjectB setSearchResults:temp];
  }
  </code></pre>
  
  <p>Now this all works except I do not get the content of temp passed on into the function in B.m. I'ts empty (nil). This is my problem. </p>
  
  <p>I'm fairly new to iOS so all help would be appreciated.</p>
  
  <p>EDIT: Forgot to mention that I'm using ARC.</p>