I know this question has been asked countless of times. But none of them seems to be working! Please help! I am unable to pass arrays from one class to another. Blow are my codes
firstClass has an array declared
#FirstClass.h
- (void)viewDidLoad
{
testArray = [[NSMutableArray alloc] init];
[testArray addObject:@"test"];
[testArray addObject:@"test2"];
[testArray addObject:@"test3"];
//method to pass array
TableViewController *tvc = [[TableViewController alloc] init];
tvc.getData = [[NSMutableArray alloc] init];
tvc.getData = testArray;
NSLog(@"%i", [tvc.getData count]); // returns a value n
Here i get count of 3
}
TableViewController.h
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%i", [getData count]); // returns a value n
Here i get 0
//Set the title
self.navigationItem.title = @"Countries";
}
I tried
FirstClass *fc = [[FirstClass alloc] init];
getData = fc.testArray;
Doesn't work as well. I tried writing a method and calling the method from my second class.
Ended up with @interface error.
Sorry, this is my first time on objective c. Am java educated.
Please help!