• 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: Satisfying a protocol - getters vs. functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Satisfying a protocol - getters vs. functions


  • Subject: Re: Satisfying a protocol - getters vs. functions
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 25 Jun 2016 12:10:08 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sypJLVT7Dd:SMTPCORP

On Jun 25, 2016, at 11:59 , William Squires <email@hidden> wrote:
>
> But would it make a difference if you have a getter named description that has type String?

They’re not interchangeable in Swift. The semantics are not even the same: getters aren’t allowed to mutate instance variables, for example (enforced by the compiler). Getters also can’t throw (though they’re talking about adding this in a later version of Swift.)

Also, the names are distinct. You won’t see that in non-mangled form, but if you think in terms of selectors, the Swift 3 selector for a function named “description" is #selector(description), while the selector a getter for a property named “description” is #selector(getter:description).

_______________________________________________

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


References: 
 >Satisfying a protocol - getters vs. functions (From: William Squires <email@hidden>)

  • Prev by Date: Satisfying a protocol - getters vs. functions
  • Next by Date: Re: Are NSFileWrappers safe for concurrent access?
  • Previous by thread: Satisfying a protocol - getters vs. functions
  • Next by thread: Re: Satisfying a protocol - getters vs. functions
  • Index(es):
    • Date
    • Thread