It sounds like you're not retaining tripDetails object, so it's getting released before you try to use.
views:
339answers:
4You should post the code that calls initWithNibName:bundle:
.
My hunch is that you're creating one programatically, but the one that's actually getting used is being created in a NIB file. Maybe your main view NIB creates a TripDetailsController as a tab view or navigation root. In that case, initWithCoder:
gets called instead of initWithNibName:bundle:
, which would explain the uninitialized td
ivar.
Wait, I have seen this before:
Instead of making a custom initializer, use the standard one and try this:
TripDetails td = ...; // td has a value
TripDetailsController *tdController = [[TripDetailsController alloc] initWithNibName:@"TripDetailsController" bundle:[NSBundle mainBundle]];
[tdController setTripDetails:td]
[self.navigationController pushViewController:tdController animated:YES];
[tdController release];
Original answer: In the TripDetailsController interface, is the thipDetails property set to retain? (and not assign).
I found a way to get it working by following the sample code from the SimpleDrillDown example from Apple.
Main differences with my original code:
- TripDetailsController is no longer defined in .xib file
- TripDetailsController no longer loaded from .xib file, but initialized as follows:
Code:
TripDetailsController *tdController =
[[TripDetailsController alloc] initWithStyle:UITableViewStyleGrouped];
- TripDetailsController is no longer a UIViewController, but a subclass of UITableViewController
As a result I had to tweak the layout a bit, but at least it now works.
Looks as if it is not possible to initialize a view controller from a XIB file and then push it on to the navigation controller.
Gero