Can someone please advise on how to pass an array of NSStrings from a ViewController into a TableViewController. I have tried using prepareForSegue in my rootViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
TableViewController *transferViewController = segue.destinationViewController;
NSLog(@"Segue %@", segue.identifier);
if ([segue.identifier isEqualToString:@"segueAffiliation"])
{
// segue Affiliation happened
transferViewController.titleText = @"Friendly";
}
else if ([segue.identifier isEqualToString:@"segueCategory"])
{
// segue Category happened
}
else if ([segue.identifier isEqualToString:@"segueFunction1"])
{
// segue Function1 happened
}
else if ([segue.identifier isEqualToString:@"segueFunction2"])
{
// segue Function2 happened
}
else if ([segue.identifier isEqualToString:@"segueFunction3"])
{
// segue Function3 happened
}
and I am not sure on how to pass the data, so far I have this in the TableViewController
@interface TableViewController ()
@end
@implementation TableViewController
{
NSArray *_tableData;
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Initialize table data
self.cellTitle.text = self.titleText;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [_tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}