I have two pairs (.m and .h) of files. In one's interface section, I've defined a global BOOL variable. I need to get it's value in another class. How can I do it? (I can't make one class a subclass of another).
In one file I have
@interface TabBarRotation : UITabBarController {
BOOL portrait;
}
@end
@implementation TabBarRotation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void):(UIInterfaceOrientation) interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
portrait=YES;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
portrait=NO;
}
}
@end
And in another's @implementation I have
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if(portrait==YES) {
CalcPortraitViewController *CalcPortraitController;
CalcPortraitController = [[CalcPortraitViewController alloc]
initWithNibName:@"CalcPortraitView" bundle:nil];
CalcPortraitController.title=@"Калькулятор";
CalcPortraitController.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:CalcPortraitController
animated:NO];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
else if (portrait==NO) {
CalcLandscapeViewController *CalcLandscapeController;
CalcLandscapeController = [[CalcLandscapeViewController alloc]
initWithNibName:@"CalcLandscapeView" bundle:nil];
CalcLandscapeController.title=@"Калькулятор";
CalcLandscapeController.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:CalcLandscapeController
animated:NO];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
}