Re: Validating NSButton in Swift
Re: Validating NSButton in Swift
- Subject: Re: Validating NSButton in Swift
- From: Quincey Morris <email@hidden>
- Date: Sun, 13 Dec 2015 15:18:37 -0800
- Feedback-id: 167118m:167118agrif8a:167118sMq8b-DuqV:SMTPCORP
On Dec 13, 2015, at 14:59 , Luc Van Bogaert <email@hidden> wrote:
>
> I have a NSButton subclass that I want to conform to NSValidatedUserInterfaceItem, so I can call validateUserInterfaceItem: on a validator passing the button as a parameter. This requires my subclass to implement two methods: action() and tag(). The compiler complains about the selectors being identical to the 'action' and 'tag' selectors in superclass NSControl.
What do your subclass implementations look like (the signature, not the body)?
According to the documentation, NSControl already has the conforming properties, so you don’t need to define your own. Just assign the correct values to the existing properties.
However, the Swift version of NSValidatedUserInterfaceItem declares the properties as methods, so this may be confusing the issue. In Obj-C, it’s all the same thing — the getter for “action” is also the method “action”, but I’m not sure what happens during bridging. (It ought to realize they’re the same thing.)
What happens if you *don’t* declare action and tag in your subclass? Is there a non-conformance warning?
_______________________________________________
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