Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-14 Thread Quincey Morris
On May 14, 2015, at 08:40 , William Squires wsqui...@satx.rr.com wrote: I'd like to know how to properly write a value transformer in Swift. Something like this, I expect: class StringNotNilTransformer: NSObject { static var transformedValueClass: AnyClass { return

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-14 Thread William Squires
Thanks, I didn't even think of that, but yeah, it would be easier. Still, I'd like to know how to properly write a value transformer in Swift. On May 12, 2015, at 5:38 PM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On May 12, 2015, at 14:29 , William Squires

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-13 Thread Quincey Morris
On May 12, 2015, at 22:19 , Uli Kusterer witness.of.teacht...@gmx.net wrote: I think at least one of those should be “message” instead of “messageIsEmpty” … ? Indeed — the second one. I’m also not absolutely sure that a computed static property will have the desired effect. It may have to

Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread William Squires
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

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Jens Alfke
On May 12, 2015, at 2:29 PM, William Squires wsqui...@satx.rr.com wrote: but the example in the documentation is in ObjC, not Swift, and refers to id, not to Bools or Strings. Hints, anyone? ‘id’ in Obj-C is ‘AnyObject’ in Swift. You’ll need to use the “as” or “as?” operator to type-cast

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Quincey Morris
On May 12, 2015, at 15:38 , Quincey Morris quinceymor...@rivergatesoftware.com wrote: dynamic var message: String dynamic var messageIsEmpty: Bool {return String == “”} static var keyPathsForValuesAffectingMessageIsEmpty: NSSet {return NSSet (object: messageIsEmpty”)} FWIW, a Swift-ier

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Quincey Morris
On May 12, 2015, at 14:29 , William Squires wsqui...@satx.rr.com wrote: class IsNotEmptyTransformer : NSValueTransformer { } but the example in the documentation is in ObjC, not Swift, and refers to id, not to Bools or Strings. Hints, anyone? Using a value transformer at all seems like

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Uli Kusterer
On 13 May 2015, at 00:38, Quincey Morris quinceymor...@rivergatesoftware.com wrote: static var keyPathsForValuesAffectingMessageIsEmpty: NSSet {return NSSet (object: messageIsEmpty”)} I think at least one of those should be “message” instead of “messageIsEmpty” … ? Cheers, -- Uli Kusterer