I want to be able to share data between table views for an app that I m making. The reason for this is that I want to be able to tell a subview which table row was selected so that I don t have to make a bunch of views and I can just test to see what the integer variable was. I watched a video tutorial on how to do this but they did not use tableviews. So when I tried this it did not seem to work. I used the app delegate as a "data center" that held that variables and then I tried to assign values to the variables in didSelectRowAtIndexPath
method. (Pushing the new view works fine by the way it s just the shared application)
Here s the code for the first tableview where I assign the variable to a number.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
ApplicationAppDelegate *appDelegate = (ApplicationAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.rowPicked = row;
SecondLevelViewController *nextController = [self.controllers objectAtIndex:row];
[self.navigationController pushViewController:nextController animated:YES];
}
在指定代表中,我这样做,我将其综合整理成:
@property (nonatomic) NSInteger rowPicked;
As well as other NSIntegers that I needed. Any suggestions? If you think I m doing this totally wrong could you please enlighten me with specific instructions or a link to a website or video tutorial? Thank you all!