Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing array between view controllers?
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload