aneuryzm
aneuryzm

Reputation: 64874

Please explain me why I can't set this UIButton hidden

Please explain me why:

[inboxB setHidden:YES];
NSLog(@"is hidden ? %i", [inboxB isHidden]); // gives 0

inboxB is an outlet. I'm inside this initializer:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    ...

thanks

Upvotes: 1

Views: 746

Answers (2)

cobbal
cobbal

Reputation: 70795

Most likely inboxB is nil at the time when you set it.

Messages to nil fail silently and (almost) always return 0. So your code would look like:

[nil setHidden:YES]; // Does nothing
[nil isHidden]; // Returns 0 or 'NO'

If it's an outlet, check to make sure you've connected it to something.

Upvotes: 2

Daniel
Daniel

Reputation: 23359

I've run into this problem a few times with getters, I believe you need to access the property directly which calls isHidden which I believe is a private method.

Try:

indoxB.hidden;

Upvotes: 0

Related Questions