Re: #selector noob question
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