Hi, i have a standard tab bar application and i am trying to pass an array from the first view to the second view but really struggling.
here is my FirstViewController.h:
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
NSArray *theArray;
}
@property (nonatomic, retain) NSArray *theArray;
@end
FirstViewController.m:
#import "FirstViewController.h"
@implementation FirstViewController
@synthesize theArray;
- (void)viewDidLoad {
[super viewDidLoad];
theArray = [NSArray arrayWithObjects:@"A",@"B", @"C",nil];
NSLog(@"theArray - %@", theArray);
}
...
its in the second view that i want to retrieve the values of the array.
SecondViewController.h:
#import <UIKit/UIKit.h>
#import "FirstViewController.h"
@interface SecondViewController : UIViewController {
}
@end
SecondViewController.m:
#import "SecondViewController.h"
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
FirstViewController *firstViewArray = [[FirstViewController alloc] init];
NSArray *arrayValues = [firstViewArray theArray];
NSLog(@"second view array - %@", arrayValues);
}
...
the result i get from NSLog is ...
second view array - (null)
and i cant figure out why it wont pass across.
any help would be greatly appreciated.