I am working on an application and I am stuck at the point where it seems I cannot get the BOOL value set in the class. I spent too much time on this, through all the questions I found that seem to cover this question.
It is bad that I get something, but not what I need (I get 0, which means, I think the value was not restored correctly, since it should be 1).
What I tried:
pass a pointer to my first class and access my BOOL as follows:
self.pointerFirstClass.myBOOL;
NSLog(@"%d", firstClass.myBOOL); => This gives 0!
declaring it (talking about a pointer) as a property in my second class (and importing the h. file from my first class, where my BOOL is declared as a property too):
@property FirstClass *pointerFirstClass;
But I got 0 using this.
Booleans , C, , - , , getter , .
getBOOLValue - (BOOL) BOOL .
.
, , , , - , .
EDIT:
. , AppDelegate (, ) WelcomeViewController ( VC).
AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
BOOL inRegion;
}
@property (strong, nonatomic) UIWindow *window;
@property BOOL inRegion;
- (BOOL)getBOOLValue;
AppDelegate.m
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
if (state == CLRegionStateInside)
{
self.inRegion = YES;
}
else if (state == CLRegionStateOutside)
{
self.inRegion = NO;
}
- (BOOL)getBOOLValue
{
return inRegion;
}
WelcomeViewControler.m( .h)
, , , .
- (IBAction)onClick:(id)sender {
AppDelegate *appDelegate = [[AppDelegate alloc] init];
if (appDelegate.inRegion) {
[self performSegueWithIdentifier:@"WelcomeToDetection" sender:self];
}
else
{
}
}
.