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 (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