Re: Validating NSButton in Swift
Re: Validating NSButton in Swift
- Subject: Re: Validating NSButton in Swift
- From: email@hidden
- Date: Mon, 14 Dec 2015 18:54:44 +0900
Oh right.
So this is a clever one.
The key in the docs might be the responder chain mentions.
The control doesn't have to validate itself.
On the contrary, usually some controller validates.
The control generally should know about state elsewhere.
Sent from my iPhone
> On Dec 14, 2015, at 6:20 PM, Quincey Morris <email@hidden> wrote:
>
>> On Dec 14, 2015, at 01:12 , email@hidden wrote:
>>
>> because it inherits from a class that conforms to the protocol
>
> NSControl conforms informally (that is, it has the requisite methods) but not formally, which isn’t conformance in Swift terms. But there’s still a conflict between properties and methods, which seems to matter to the Swift compiler, that’s preventing subclasses from adopting conformance.
>
> If you do this in a playground:
>
>> import Cocoa
>> extension NSControl : NSValidatedUserInterfaceItem { }
>
>
> You get these error messages (plus more for ’tag’):
>
>> error: type 'NSControl' does not conform to protocol 'NSValidatedUserInterfaceItem'
>> extension NSControl : NSValidatedUserInterfaceItem
>>
>> AppKit.NSValidatedUserInterfaceItem:2:17: note: protocol requires function 'action()' with type '() -> Selector'
>> public func action() -> Selector
>>
>> AppKit.NSControl:4:16: note: candidate is not a function
>> public var action: Selector { get set }
>
> That pretty much lays out what the problem is, and as 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