• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Properties: A question of style
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Properties: A question of style
      • From: Steve Mills <email@hidden>
References: 
 >Properties: A question of style (From: Graham Cox <email@hidden>)

  • Prev by Date: Properties: A question of style
  • Next by Date: Re: Properties: A question of style
  • Previous by thread: Properties: A question of style
  • Next by thread: Re: Properties: A question of style
  • Index(es):
    • Date
    • Thread