EDIT – apologies for the typo, i was in a rush, since i had to get out of the building but hmm… might i ask, why the downvotes? just because of a few syntax errors? i’m open to being critiqued, but please be constructive?
thanks for the constructive answers, i’ve given both an upvote.
=============================================
I have an iVar BOOL that i wanted to use throughout this class. i tried to initialize it to YES, but the first time i read it out, it is NO. why is that? This is strange to me because my ints are all retained.
in my .mm file I have something like this:
@interface MyClass : NSObject {
BOOL myBool;
int myInt;
}
@end
@implementation MyClass
-(id)init{
//...
myInt = 3;
myBool = YES; //here i set it
//...
[self addObjectsToGame];
//...
}
-(void)addObjectsToGame{
//...
assert(myInt == 3);
assert(myBool); // <---- this line would fail
//...
}
@end
i get that i can use a @property with assign, but why does this iVar not retain it’s value??
EDIT
okay yeah, wow, something is really messed up here… i tried to replace it with @property and it’s still not working. i then tried to “find all in project” for the variable myBool and i’m NOT changing it anywhere else
Note: i’m using cocos2d, but i dont think that should affect anything
I’ve fixed Objective-C syntax for you and everything works as expected