I have an object declared in my app delegate:
@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
ClassName *className;
}
In another class, I include the app delegate:
#import "MyAppDelegate.h"
@implementation AnotherClass
-(void)doMethod {
[className doClassNameMethod];
}
This fails at compile time due to className being undeclared. Shouldn’t it be accessible, since I’ve included the MyAppDelegate, where className is declared? I need AnotherClass.doMethod to be accessing the same instance that is created in MyAppDelegate.
Any help on this would be most appreciated. Thanks.
To access a instance variable in one class from another class, you should create a property.
From the other class you may then access this property like this: