On Mar 22, 2016, at 07:21 , Eric E. Dolecki <edole...@gmail.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to