• 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: Validating NSButton in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validating NSButton in Swift


  • Subject: Re: Validating NSButton in Swift
  • From: Luc Van Bogaert <email@hidden>
  • Date: Mon, 14 Dec 2015 08:42:57 +0100

> On 14 Dec 2015, at 00:18, Quincey Morris <email@hidden> wrote:
>
> On Dec 13, 2015, at 14:59 , Luc Van Bogaert <email@hidden <mailto: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?



I've defined the subclass like this:

class ValidatedButton: NSButton, ValidatedControl {


I've defined ValidatedControl like this:

protocol ValidatedControl: NSValidatedUserInterfaceItem {


This results in a compiler error: Type ValidatedButton does not conform to protocol NSValidatedUserInterfaceItem.
I've tried overriding the NSControl properties 'action' and 'tag', but the error remains.

--
Luc
_______________________________________________

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


  • Follow-Ups:
    • Re: Validating NSButton in Swift
      • From: Roland King <email@hidden>
References: 
 >Validating NSButton in Swift (From: Luc Van Bogaert <email@hidden>)
 >Re: Validating NSButton in Swift (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Validating NSButton in Swift
  • Next by Date: Re: Validating NSButton in Swift
  • Previous by thread: Re: Validating NSButton in Swift
  • Next by thread: Re: Validating NSButton in Swift
  • Index(es):
    • Date
    • Thread