I would like to pass a string to all my other view controllers from the AppDelegate
. I have defined a variable called appName
and assign it a string
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSString *appName;
@end
AppDelegate.m
@implementation AppDelegate
@synthesize appName;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
appName=@"SatKacPara";
return YES;
}
The following implementation does not have access to appName
property. I could not able to figure out.
ViewController1.m
appLabel.text=[(AppDelegate*) [UIApplication shareApplication].delegate ].appName;