The Problem
An IBOutlet is released before I have a chance to use it.
What I Want
I want to access a navigation controller from my app delegate so I can reload a table view.
My Setup
I have:
- A Main.xib that's set as my main interface in target settings
- An IBOutlet to the navigation controller as an ivar on my app delegate
- This IBOutlet hooked up to the correct navigation controller in Main.xib
- App Delegate is instantiated in the xib but not set as File's Owner
I'm using ARC, Xcode 4.3.2 and iOS5.1
What I've Tried
- Changing deployment target
- Putting a break point on dealloc for the navigation controller, app delegate - they're never called
- Reading everything I can find on ARC and IBOutlets - nothing seems to contradict what I'm doing
- Creating a fresh project with just a the minimum classes required - I see exactly the same problem
Code
KPAppDelegate.h
@interface KPAppDelegate : UIResponder <UIApplicationDelegate> {
IBOutlet KPBrowseExpensesNavigationController *nc;
}
@property (strong) IBOutlet KPBrowseExpensesNavigationController *nc;
KPAppDelegate.m
@implementation KPAppDelegate
@synthesize nc;
-(void)setNc:(KPBrowseExpensesNavigationController *)nc_ {
nc = nc_; // This gets called on view load and nc gets set.
}
...snip...
// This is called about 5 seconds after app startup
-(void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects {
// By the time we get here, nc is nil.
UITableViewController *tvc = [[nc viewControllers] objectAtIndex:0];
[[tvc tableView] reloadData];
}
@end
UPDATE
I must be doing something really silly here. Even an incredibly simple project still shows this problem. See link below.