Please do not create 21 different view controller's just to show different items. Instead set a property on GlossaryDetailViewController that holds an instance of your data model item Consider this (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = indexPath row; if (self. GlossaryDetailViewController == nil) { GlossaryDetailViewController *aGlossaryDetail = GlossaryDetailViewController alloc initWithNibName:@"GlossaryDetailViewController" bundle:nil; self.
GlossaryDetailViewController = aGlossaryDetail; aGlossaryDetail release; } glossaryDetailViewController. GlossaryDetailItem = glossaryArray objectAtIndex:row; self. NavigationController pushViewController:self.
GlossaryDetailViewController animated:YES; } Using this approach make the GlossaryDetailViewController responsible for setting it's own data Edit You'll also notice that I removed references to the app delegate. You don't need it to get access to the navigation controller. Each view controller in a navigation controller stack has a reference to it.
While I'm thoroughly tearing your code apart, I would also factor out the creation of the view controller by overriding the getter for glossaryDetailViewController like this: (GlossaryDetailViewController *)glossaryDetailViewController { if (!glossaryDetailViewController) { glossaryDetailViewController = GlossaryDetailViewController alloc init; } return glossaryDetailViewController; } If you go this route, you can remove the if statement and just call self. GlossaryDetailViewController.
Please do not create 21 different view controller's just to show different items. Instead set a property on GlossaryDetailViewController that holds an instance of your data model item. Consider this... - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = indexPath row; if (self.
GlossaryDetailViewController == nil) { GlossaryDetailViewController *aGlossaryDetail = GlossaryDetailViewController alloc initWithNibName:@"GlossaryDetailViewController" bundle:nil; self. GlossaryDetailViewController = aGlossaryDetail; aGlossaryDetail release; } glossaryDetailViewController. GlossaryDetailItem = glossaryArray objectAtIndex:row; self.
NavigationController pushViewController:self. GlossaryDetailViewController animated:YES; } Using this approach make the GlossaryDetailViewController responsible for setting it's own data. Edit You'll also notice that I removed references to the app delegate.
You don't need it to get access to the navigation controller. Each view controller in a navigation controller stack has a reference to it. While I'm thoroughly tearing your code apart, I would also factor out the creation of the view controller by overriding the getter for glossaryDetailViewController, like this: - (GlossaryDetailViewController *)glossaryDetailViewController { if (!glossaryDetailViewController) { glossaryDetailViewController = GlossaryDetailViewController alloc init; } return glossaryDetailViewController; } If you go this route, you can remove the if statement and just call self.
GlossaryDetailViewController.
Thanks – PatrickSerrano Apr 6 at 19:33 Sure, you subclass NSObject to make an object that will hold all of your related data that will be shown on glossaryDetailViewController. Then you would create your glossaryArray to hold those objects instead of NSStrings as you have now. Additionally you will add glossaryDetailItem as a property of glossaryDetailViewController with the same type.
– Mark Adams Apr 6 at 19:40 wow thanks, now that I am using this code, I ran into one tiny problem, I'm getting glossaryDetailViewController. GlossaryDetailItem = glossaryArray objectAtIndex:row; error because it's saying: Error: request for member 'aGlossaryDetail' in something not a structure or union. Any ideas?
Thanks – PatrickSerrano Apr 11 at 15:50 Take what you have now and roll it into a new question. I'd need to see more code to understand what's going on here. – Mark Adams Apr 11 at 18:42.
Please do not create 21 different view controllers just to show different items. Instead set a property on GlossaryDetailViewController that holds an instance of your data model item. Using this approach makes GlossaryDetailViewController responsible for setting it's own data.
You'll also notice that I removed references to the app delegate. You don't need it to get access to the navigation controller. Each view controller in a navigation controller stack has a reference to it.
If you go this route, you can remove the if statement and just call self.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.