small medium large xlarge

07 Feb 2010, 03:00
Patrick Huffer (8 posts)

I love the introduction of properties in Objective-C 2.0, but it drives me nuts that the standard libraries haven’t made use of them. For example, I’ve reached page 125 in the book, and instead of

@[sender setHidden:YES];@

I want to say something like

@sender.isHidden = YES;@

but only after digging through the header file do I realize there’s no hope of that working. I’m coming from .NET so this construction is most natural for me but I guess I have to do without :(

13 Feb 2010, 16:41
Patrick Huffer (8 posts)

Hm. Now I see in the iPhone chapter that the iPhone SDK makes greater use of properties… interesting.

22 Apr 2010, 18:00
Michael Weller (6 posts)

I only have experience with the iPhone, but as long as an object has setX and x methods, you can use Ob-C 2.0 properties with it.

sender.isHidden = YES

is simply translated to [sender setHidden:YES];

The only problem you will have is that auto-completion doesn’t play nice because there is no formal @property declaration.

27 Oct 2010, 13:18
Matthew Whillock (8 posts)

Another to remember is that many boolean properties have their getter defined with the prefix “is” (“isHidden”, for example) but the property is “hidden” so the dot notation is sender.hidden = YES;. Try forgetting the “is” when using dot notation.

You must be logged in to comment