Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:17:32+00:00 2026-06-14T15:17:32+00:00

EDIT – apologies for the typo, i was in a rush, since i had

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:17:33+00:00Added an answer on June 14, 2026 at 3:17 pm

    I’ve fixed Objective-C syntax for you and everything works as expected

    #import <Foundation/Foundation.h>
    
    @interface MyClass : NSObject {
        BOOL myBool;
        int myInt;
    }
    -(void)addObjectsToGame;
    @end
    
    @implementation MyClass
    
    -(id)init{
        if (self = [super init])
        {
            myInt = 3;
            myBool = YES; //here i set it
            [self addObjectsToGame];
        }
        return self;
    }
    
    -(void)addObjectsToGame{
        assert(myInt == 3);
        assert(myBool);
        NSLog(@"OK");
    }
    
    @end
    
    
    int main(int argc, char *argv[]) {
        @autoreleasepool {
            [MyClass new];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I think I figured out the solution, but I'm still interested to know
Edit: This question looks like it might be the same problem, but has no
EDIT Leaving this for posterity, but nearly a year later, to get down voted,
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT : It turned out that this can only be done through an external
Edit: The initial question was wrong, so some of the content might be a
EDIT: More detail here. Basically if you 1. open a tab1 to url1 (GET
EDIT : Ok, I found out why. My getX and getY were overriding the
EDIT: I think I've worked something out. - This character - ’ - seems
EDIT: I'd like to get a definitive answer on whether or not it's possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.