インスタンス化してnavigationControllerにプッシュしたものとは異なるHistoryViewControllerのインスタンスを取得するのはなぜですか?
作成された別のインスタンスには、設定したプロパティがありません。
ProfileHomeViewController.m
HistoryViewController *historyViewController = nil;
historyViewController = [[HistoryViewController alloc] initWithNibName:@"HistoryViewController" bundle:nil];
// nib has identity of NSObject (I also tried HistoryViewController), and tableviewcontroller with identity HistoryViewController
historyViewController.profile = self.profile;
NSLog(@"%@ > %@", self, self.managedObjectContext);
// <ProfileHomeViewController: 0x5b34330> > <NSManagedObjectContext: 0x7918770>
historyViewController.managedObjectContext = self.managedObjectContext;
NSLog(@"%@ > %@", historyViewController, historyViewController.managedObjectContext);
// <HistoryViewController: 0x792a870> > <NSManagedObjectContext: 0x7918770>
[self.navigationController pushViewController:historyViewController animated:YES];
[historyViewController release];
HistoryViewController.h
@interface HistoryViewController : UITableViewController {
NSManagedObject *profile;
NSFetchedResultsController *fetchedResultsController;
NSManagedObjectContext *managedObjectContext;
}
@property (nonatomic, retain) NSManagedObject *profile;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
HistoryViewController.m
@implementation HistoryViewController
@synthesize profile;
@synthesize fetchedResultsController;
@synthesize managedObjectContext;
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"inside HistoryViewController %@ > profile %@", self, self.profile);
// inside HistoryViewController <HistoryViewController: 0x7917750> > profile (null)
NSLog(@"inside HistoryViewController %@ > managedObjectContext %@", self, self.managedObjectContext);
// inside HistoryViewController <HistoryViewController: 0x7917750> > managedObjectContext (null)
if(self.managedObjectContext == nil){
NSLog(@"invalid managedObjectContext WTF");
abort();
}
}