views:

96

answers:

2

Hi,

So I'm calling this:

[leftSwitch hidden:NO];

but the iPhone Simulator just crashes (no compiler errors) when I click on the Segmented Control that calls the IBAction that this code is from.

However, as soon as I change this to:

leftSwitch.hidden = NO;

it works...I made no other changes.

+10  A: 

You want

[leftSwitch setHidden:NO];

Note the automatic change in name-- the method version gets the set prefix.

quixoto
oh i totally forgot about that...i was only thinking of the "is" prefix for boolean accessors
Devoted
+3  A: 

The default methods synthesized for properties are

[foo bar]

which is the getter, and

[foo setBar:other]

which is the setter.

But the property shorthand allows you to access these methods by using dot notation so it appears that you are accessing like any other ivar, but you are really using these synthesized properties in the background. in the property declaration, you can change the default names, but it is best to leave it based on the normal Objective C conventions.

Brandon Bodnár