Passando a matriz entre os controladores de exibição?
Eu realmente preciso de mais ajuda!
Estou tentando passar uma matriz de um controlador de exibição para outro. Eu acho que este último é um controlador de exibição 'filho'?
Meu código é o seguinte:
MainViewController.h:
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface HelloWorldIOS4ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, AVAudioPlayerDelegate> {
NSMutableArray *countProductCode;
UIPopoverController *detailViewPopover;
}
@property (nonatomic, retain) NSMutableArray *countProductCode;
@property (nonatomic, retain) UIPopoverController *detailViewPopover;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
...
@end
MainViewController.m
#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;
}
PopoverViewController.h:
@interface PopoverContentViewController : UITableViewController {
NSMutableArray *countProductCodes;
}
@property (nonatomic, retain) NSMutableArray *countProductCodes;
@end
PopoverViewController.m:
#import "PopoverContentViewController.h"
#import "HelloWorldIOS4ViewController.h"
@implementation PopoverContentViewController
@synthesize countProductCodes;
...
Eu cortei muito, mas eu sei que, a partir de uma carga de NSLog's espalhados, recebo os dados de volta, etc., mas não consigo passar a matrizcountProductCode
aoPopoverViewController's
countProductCodes
array.
Eu continuo recebendo
"Acessando o método de classe desconhecido 'setCountProductCodes:'"
erros.
Isso pode ser algo realmente bobo que estou fazendo, mas está me deixando louco!
Alguém pode ajudar por favor?
Obrigado James