According to this answer, I'm trying to declare and define global variable and getting this error:
Undefined symbols for architecture armv7: "_loggedIn", referenced from: -[XYZAppDelegate application:didFinishLaunchingWithOptions:] in XYZAppDelegate.o -[XYZFolderViewController viewDidAppear:] in XYZFolderViewController.o -[XYZFolderViewController loginViewController:didEnterUsername:password:] in XYZFolderViewController.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've found many answers here, but all of them are referring to different problem(s) (as much as I can say).
XYZAppDelegate.h
... extern BOOL loggedIn; ...
XYZAppDelegate.m:
... @implementation XYZAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { loggedIn = 0; ... } ...
XYZFolderViewController.h
... extern BOOL loggedIn; ...
XYZFolderViewController.m
... @implementation ... - (void)loginViewController:(XYZLoginViewController *)loginViewController didEnterUsername:(NSString *)username password:(NSString *)password { ... if ([username isEqualToString:theUsername] && [password isEqualToString:thePassword]) { loggedIn = 1; /* 0 == not logged in. 1 == logged in. */ ... } ... }
Point of this global variable is holding information about user being logged in (or not) into app.
I am aware that using extern
in Objective-C is not clean approach. However, besides extern
usage, I'd appreciate hints for solutions of other kind.
Expecting this is rookie question.