How to address/reference my button


I’ve finished the simple app but I want to make some changes to it an I am stumpped. How do I reference my button?

I know that I should be able to do something like [myButton enabled:YES] but I can’t figure out the name of the button. I can seek it’s text in the Attributes Inspector but I don’t see the variable/item/? name for the button.


To reference a button or any UI control for that matter configured in an XIB document, you need to add an outlet to a file’s-owner-to-be class like this:

@interface Foo
@property (assign) IBOutlet UIButton *outletMyButton;

Then make the class (here Foo) the owner of the XIB document that contains the button, and then in IB setup the connection from the button to Foo (here Foo is the file’s owner.)

After that you can access the button.

Keep reading the book; these things will be covered in detail.


Thanks for the help.

I was trying to disable the show answer button until a question is revealed but couldn’t figure it out. I’ll just wait until it is revealed. I have an inquisitive mind and a tendency to jump ahead. Instead I guess I should just keep to the pace of the book. Tough to do but probably the best approach.