• 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: #selector noob question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #selector noob question


  • Subject: Re: #selector noob question
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 22 Mar 2016 09:44:36 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sTLNV9zcJY:SMTPCORP

On Mar 22, 2016, at 07:21 , Eric E. Dolecki <email@hidden> wrote:
>
> myButton.addTarget(self, action: #selector(AudioElement.selected(_:)), forControlEvents: .TouchUpInside)
> I get it now that I can see what's going on with better context. I can also just replace AudioElement with self.

It’s slightly better than that. Since ‘self’ is the observer, ‘selected(_:)’ is one of its own instance methods, so you don’t need to specify the class or ’self':

> 	#selector (selected(_:))


If in addition the name of the method (selected) is unambiguous within the class of ‘self’, you don’t need to specify the parameters either:

> 	#selector (selected)


This doesn’t mean it doesn’t matter whether there’s a parameter or not, just that the Swift compiler can figure it out for you if you point it in the right direction.
_______________________________________________

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: 
 >#selector noob question (From: "Eric E. Dolecki" <email@hidden>)
 >Re: #selector noob question (From: Quincey Morris <email@hidden>)
 >Re: #selector noob question (From: Luther Baker <email@hidden>)
 >Re: #selector noob question (From: "Eric E. Dolecki" <email@hidden>)
 >Re: #selector noob question (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: NSThread to NSOperation and blockUntil
  • Next by Date: Re: NSThread to NSOperation and blockUntil
  • Previous by thread: Re: #selector noob question
  • Next by thread: IKImageBrowserView bug?
  • Index(es):
    • Date
    • Thread