title: Passing array between view controllers?
body: <p>I really need some more help!</p>
  
  <p>I am trying to pass an array from one view controller to another. I think the latter being a 'child' view controller?</p>
  
  <p>My code is as follows:</p>
  
  <p>MainViewController.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;AudioToolbox/AudioToolbox.h&gt;
  #import &lt;AVFoundation/AVFoundation.h&gt;
  
  @interface HelloWorldIOS4ViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, AVAudioPlayerDelegate&gt; {
      NSMutableArray  *countProductCode;
      UIPopoverController *detailViewPopover;
  }
  
  @property (nonatomic, retain) NSMutableArray  *countProductCode;
  
  @property (nonatomic, retain) UIPopoverController *detailViewPopover;
  
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
  ...
  @end
  </code></pre>
  
  <p>MainViewController.m</p>
  
  <pre><code>#import "HelloWorldIOS4ViewController.h"
  #import "JSON.h"
  #import "PopoverContentViewController.h"
  
  @implementation HelloWorldIOS4ViewController
  
  @synthesize detailViewPopover;
  @synthesize countProductCode;
  
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
  {
      NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  
      NSDictionary *results = [jsonString JSONValue];
      NSLog(@"RETURN: %@", results);
  
      [countProductCode removeAllObjects];
  
      NSArray *products = [results objectForKey:@"items"];
  
      for (NSDictionary *row in products)
      {
          NSString *code = [row objectForKey:@"ic"];
          [countProductCode addObject:code];
      }
  
      PopoverContentViewController.countProductCodes = countProductCode;
  }       
  </code></pre>
  
  <p>PopoverViewController.h:</p>
  
  <pre><code>@interface PopoverContentViewController : UITableViewController {
      NSMutableArray  *countProductCodes;
  }
  @property (nonatomic, retain) NSMutableArray  *countProductCodes;
  @end
  </code></pre>
  
  <p>PopoverViewController.m:</p>
  
  <pre><code>#import "PopoverContentViewController.h"
  #import "HelloWorldIOS4ViewController.h"
  
  @implementation PopoverContentViewController
  
  @synthesize countProductCodes;
  ...
  </code></pre>
  
  <p>I have cut a lot out, but I know from a load of NSLog's dotted around that I get the data back etc, but I cannot pass the array <code>countProductCode</code> to the <code>PopoverViewController's</code> <code>countProductCodes</code> array.</p>
  
  <p>I keep getting </p>
  
  <blockquote>
    <p>"Accessing unknown 'setCountProductCodes:' class method"</p>
  </blockquote>
  
  <p>errors.</p>
  
  <p>This may be something really silly that I'm doing but it's driving me crazy!</p>
  
  <p>Can anyone help please?</p>
  
  <p>Thanks
  James</p>