Re: Properties: A question of style
Re: Properties: A question of style
- Subject: Re: Properties: A question of style
- From: Charles Srstka <email@hidden>
- Date: Tue, 14 Jun 2016 19:45:59 -0500
> On Jun 14, 2016, at 6:48 PM, Graham Cox <email@hidden> wrote:
>
> Hi all,
>
> Just a quick point for discussion.
>
> Suppose I have a read-only BOOL property. What’s better, to declare it as:
>
> @property (readonly) BOOL isFoo;
>
> or:
>
> @property (readonly, getter=isFoo) BOOL foo;
>
>
> Is there any advantage to one over the other? n.b. I’d always use the latter form for read/write properties, it’s readonly ones that I’m wondering about.
>
> —Graham
The former is what Apple’s recommending in the Swift guidelines, so it’s probably the more future-proof of the two.
I’ve always felt this style to read more naturally, too.
if thisArray.isEmpty { doSomething() } // reads as “If this array is empty, do something."
if thisArray.empty { doSomething() } // reads as “Grok say this array empty! Grok do something! GRARRRGH! ::conks you on the head with a club::"
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden