Aggravation trying to implement NSValueTransformer subclasses in Swift
Aggravation trying to implement NSValueTransformer subclasses in Swift
- Subject: Aggravation trying to implement NSValueTransformer subclasses in Swift
- From: William Squires <email@hidden>
- Date: Tue, 12 May 2015 16:29:04 -0500
I'm trying to make what should be a fairly simple value transformer. I need to bind the Enabled state of a control (NSButton in this case, but it could be any control) to the .isEmpty state of a string. I would think this a common enough task that an existing value transformer would be supplied, but I guess not. Unfortunately, the documentation only gives a sample in ObjC, but not Swift.
I have the following:
class MyWindowController : NSWindowController
{
dynamic var message: String
override var windowNibName: String
{
return "MyWindowController"
}
...
}
there's an NSTextField in the window, and it's value is bound to the "message" variable with bindings; simple enough. There's also a button whose enabled status I want controlled based on if the value of "message" is the empty string, so I make:
class IsNotEmptyTransformer : NSValueTransformer
{
}
but the example in the documentation is in ObjC, not Swift, and refers to id, not to "Bool"s or "String"s. Hints, anyone?
_______________________________________________
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