BOOL changing value in objective-C?


BOOL changing value in objective-C?



I am having trouble with a BOOL property and I can't quite figure it out.

I have the following set in my .h file:

BOOL myVar;  @property BOOL myVar; 

Then in my .m file I synthesize myVar and have a method that set myVar = YES; and also starts a timer. The timer then calls another method that tries to read the value of myVar.

To test for the value of myVar I have:

NSLog(@"The value of the bool is %@\n", (myVar ? @"YES" : @"NO")); 

The first loop through the console shows myVar = YES then after that it says NO.

How do I keep it as the value of YES? Is it already YES but my NSLog is wrong? I need to test for YES/NO in that method because the actions taken will vary depending on their value.




Method in Objective-C that points to an object

1:



Is it possible to declare a method as private in Objective-C?
Set a watch point on myVar to find out if it actually changes, with out seeing more source code we can't tell you what is going on :).
Objective C: Modulo bias


UIScrollview with UIButtons - how to recreate springboard?


Why do Objective C files use the .m extension?

2:



How to Convert NSInteger to a binary (string) value
The reason it was failing was because I was comparing (myVar = YES) instead of (myVar == YES.).
Why has NSNumber such strange retainCounts?
Yeah -- I am new..
Modulo with long long integers in Objective C



82 out of 100 based on 52 user ratings 1102 reviews