I’ve got an array populating a small tableView in a DetailView class, and when the user presses a button I need the array to be sent to another View Controller, to populate a tableView there, but I’m having some difficulty getting it working. This is what I’ve been trying to do so far:
*DetailViewController.m*
#import "DetailViewController.h"
#import "OtherViewController.h"
-(IBAction) toCart:(id)sender {
OtherViewController *oVC = [[OtherViewController alloc] init];
oVC.shoppingList = sList;
NSLog(@"Ingredients count %d", [sList count]); //This returns a number, so the sList definitely contains values, and the method is definitely being called.
[oVC release];
}
*OtherViewController.m*
#import "OtherViewController.h"
#import "DetailViewController.h"
@synthesize shoppingList;
-(void) viewWillAppear: (BOOL)animated {
NSLog(@"list count: %d", [shoppingList count]); // This returns 0
}
sList is populated elsewhere in the class, and sList and shoppingList are both declared in their respective .h files, with @property (nonatomic, retain)…
Any help much appreciated!
As you are having
taBbarcontroller, so you can proceed as follows :Create references of your you
viewControllers(which are associated withtabbarastopViewController) in yourappDelegate.make it as @property in appDelegate so that you can access it anywhere in your app.
now,
in your
appDelegate's .hwritein
appDelegate's.min
appDelegates‘s .m(methoddidFinishLaunchingWithOptions: ) writeThanks