This error very strange. I have a bunch of properties in app delegate which I have no problem to access. My code worked fine without ARC, but when I turned on ARC I receive this very strange error. Property 'navigationController' not found on object of type 'AppDelegate *'
A bunch of other properties work just fine except this.
I already clean everything and restarted Xcode.
Here is the code:
AppDelegate.h:
@interface AppDelegate : UIResponder <UINavigationControllerDelegate> {
UINavigationController *navigationController;
NSString *appName;
}
@property (strong, nonatomic) NSString *appName;
@property (strong, nonatomic) UINavigationController *navigationController;
AppDelegate.m
#import "AppDelegate.h"
@synthesize navigationController, appName;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
appName = [NSString stringWithString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]];
navigationController = [[UINavigationController alloc] initWithRootViewController:self.startViewController];
}
MyClass.h
@class AppDelegate;
@interface MyClass: UIResponder {
AppDelegate *appDelegate;
}
MyClass.m
#import "AppDelegate.h"
#import "MyClass.h"
@implementation MyClass
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self initFacebook];
}
return self;
}
- (void) doStuff {
NSLog(@"App Name:%@",appDelegate.appName); //this works fine
//This one doesn't
UINavigationController *myNavigationController = appDelegate.navigationController;
}
Update: I did a workaround. Basically I created a property in MyClass called navigationViewController and I pass the object after MyClass is instantiated in AppDelegate instead of getting directly from AppDelegate in MyCLass (as shown above). I'm still puzzled, it must be a bug in the compiler. I'm still very interested in how to make the original code work.