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 8708893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:14:25+00:00 2026-06-13T04:14:25+00:00

I am new to ios, coming from heavy UI work in C#. I have

  • 0

I am new to ios, coming from heavy UI work in C#.
I have an app that I wanna control which button are enabled disabled based on some logic in my code.
to do this I created a small method to handle the state of the buttons, like so :

-(void)activateUI:(BOOL *)activate {

    [ validateDataBtn setEnabled: *activate ] ;
    [ modifyCompDataBtn setEnabled: *activate ] ;
    [ saveCompDataBtn setEnabled: *activate ] ;
}

Where all of those IBOutlets are bound to UI buttons like so :

__weak IBOutlet UIButton *saveCompDataBtn;
__weak IBOutlet UIButton *modifyCompDataBtn;
__weak IBOutlet UIButton *validateDataBtn;

when I run the app I get an exception on the first line of my method :

[ validateDataBtn setEnabled: *activate ] ;

the error is EXC_BAD_ACCESS (code = 2, address =0X0)
what am I doing wrong?

  • 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-13T04:14:26+00:00Added an answer on June 13, 2026 at 4:14 am

    EDIT: My, my. I just realized how badly I messed this one up.

    Incorrect: First off, you shouldn’t be using BOOL *, and if you ever did use BOOL * you would reference it as &activate, not *activate. The * in C/Objective-C means the variable is a pointer; it contains an address to a block of memory. & dereferences pointers to access the value on the other side.

    Correct: An * indicates that the argument is a pointer, and is also used to deference a pointer. An & in front of a variable indicates that you want to use the address of the variable in memory. I mixed them up. This means your original code is correct; the problem is that you probably call it using [self activateUI:someBOOL], which passes a BOOL, then tries to deference it like a pointer due to the *.

    You might be getting confused since objects are passed as <object type> * because all variables used to handle instances of objects are pointers. BOOL, however, is typedefed to int, which is primitive, thus the * is not needed. Your method should be:

    - (void) activateUI:(BOOL)activate {
        [validateDataBtn setEnabled: activate];
        [modifyCompDataBtn setEnabled: activate];
        [saveCompDataBtn setEnabled: activate];
    }
    
    //called like this: [self activateUI: someBOOL];
    

    If you really DID mean to pass a pointer to a BOOL as an argument use what you originally wrote, but you need to call it like this:

    [self activateUI: &someBOOL];
    

    If you declare the method to take a pointer to a BOOL (BOOL *), and dereference it inside the method body (*someBOOL), you need to pass the address to the BOOL (&someBOOL), not the BOOL itself. If you declare the method to take a BOOL itself (just BOOL), and use it directly in the method body (someBOOL), you need to pass the BOOL itself (someBOOL).

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

Sidebar

Related Questions

fairly new to Objective-C and iOS development (coming from PHP) and I have a
I'm trying to make an iOS 5 app that features real-time things coming from
I am new to IOS and coming from pcs I am trying to get
I am new to Mac/iOS development. I am coming over from C# .net. My
i am very new to ios development, rather i have just started work on
New to iOS, coming from the Java / Swing world, where I'm used to
I'm pretty new to mac development (coming from a web and iOS background) and
A new iOS ViewControllers created from a template contains several boilerplate methods that call
i am pretty new to the iOS world and since I'm coming from the
I'm writing my first android app and coming from the iOS world. I've got

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.