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

  • SEARCH
  • Home
  • 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 6833635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:00:11+00:00 2026-05-26T23:00:11+00:00

I am trying to access my UIButton in my Play class from my CCLayerClass.

  • 0

I am trying to access my UIButton in my Play class from my CCLayerClass.

The problem is that it is not working!

Here is how I declare it in the Play class:
.h

IBOutlet UIButton *pauseButton;
@property(nonatomic, retain) IBOutlet UIButton *pauseButton;

.m

@synthesize pauseButton;

Then in the dealloc:

[pauseButton release];

Also of course I connect it then in Interface builder.

Then in my other class (My CCLayer) class. I try to do this:

Play *play = [[[Play alloc] init] autorelease];
[play.pauseButton setHidden:YES];

The thing is, is that it simply just does not hide the button. Is there any reason for this?

Thanks!

Edit1:
My Play.h

IBOutlet UIButton *pauseButton;
BOOL pauseButtonVisible;

@property(nonatomic, retain) IBOutlet UIButton *pauseButton;
@property(readwrite) BOOL pauseButtonVisible;

.m

@synthesize pauseButton;

- (void)setPauseButtonVisible: (BOOL) variableToSet {
    pauseButtonVisible = variableToSet;
    if(pauseButton)
        [pauseButton setHidden: !pauseButtonVisible];
}
- (BOOL) pauseButtonVisible
{
    return(pauseButtonVisible);
}

viewWillAppear:

[pauseButton setHidden: !pauseButtonVisible];

I also made sure I connected it in Interface Builder

Then in CCLayerClass I do this:

Play *play = [[[Play alloc] init] autorelease];
    if(play.pauseButton == NULL) {  
        NSLog( @"pause button is NULL");
    }

But that NSLog gets called! Why is my pauseButton NULL? I just need to alloc it so it stays alive, is that possible?

Thanks!
play.pauseButtonVisible = YES;

  • 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-05-26T23:00:11+00:00Added an answer on May 26, 2026 at 11:00 pm

    Okay. Hopefully third time is the charm (and after that, I’m giving up cause it’s time for me to go to bed).

    Here in the .h file, I’m keeping the new pauseButtonVisible BOOL property.

    @interface Play : UIViewController
    {
        BOOL pauseButtonVisible;
        IBOutlet UIButton *pauseButton;
    }
    
    @property(nonatomic, retain) IBOutlet UIButton *pauseButton;
    @property(readwrite) BOOL pauseButtonVisible;
    
    @end    
    

    But in the .m file, we’re doing something a little different:

    @interface Play
    
    // here we are rolling our own setters and getters
    // instead of @synthesizing...
    - (void)setPauseButtonVisible: (BOOL) variableToSet
    {
        pauseButtonVisible = variableToSet;
        if(pauseButton)
            [pauseButton setHidden: !pauseButtonVisible];
    }
    
    - (BOOL) pauseButtonVisible
    {
        return(pauseButtonVisible);
    }
    
    - (void) viewWillAppear: (BOOL) animated
    {
        [pauseButton setHidden: !pauseButtonVisible];
        [super viewWillAppear: animated];
    }
    

    and

    Play *play = [[[Play alloc] init] autorelease]; // you should really be using initWithNibName, but anyways
    play.pauseButtonVisible = YES;
    

    So now, hopefully pause button will be visible or hidden at the appropriate time for while your code is running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PROBLEM: I'm trying access binary records that were created in Borland Delphi and stored
Trying to access a property from the parent page on my user control. Here's
Im trying to access a web service from a remote computer. I managed to
I am trying to access Outlook 2007 from C#. I have installed the PIA
I am trying to access a view inside a splitter from my mainframe. At
I have a couple UIViewControllers that I am trying to access an array inside
I am trying to access Facebook from Python :D I want to fetch some
I'm trying to access 1.20163 from the following: 1 British Pound Sterling = 1.20163
Im trying to access some variables from the parent in a child mc. Parent
I am trying to access static member of a class. my class is: class

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.