Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-14 Thread Quincey Morris
On May 14, 2015, at 08:40 , William Squires 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 NSNumber.self } > sta

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 wrote: > On May 12, 2015, at 14:29 , William Squires wrote: >> >> class IsNotEmptyTransformer : NSValueTr

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-13 Thread Quincey Morris
On May 12, 2015, at 22:19 , Uli Kusterer 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 be a static method. But pe

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Uli Kusterer
On 13 May 2015, at 00:38, Quincey Morris 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 “The Witnesses of TeachText are ev

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Quincey Morris
On May 12, 2015, at 15:38 , Quincey Morris wrote: > > dynamic var message: String > dynamic var messageIsEmpty: Bool {return String == “”} > static var keyPathsForValuesAffectingMessageIsEmpty: NSSet {return NSSet > (object: "messageIsEmpty”)} FWIW, a Swift-ier way to do this might be somethin

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift

2015-05-12 Thread Quincey Morris
On May 12, 2015, at 14:29 , William Squires wrote: > > 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? Using a value transformer at all seems like a poor cho

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 wrote: > > but the example in the documentation is in ObjC, not Swift, and refers to id, > not to "Bool"s or "String"s. Hints, anyone? ‘id’ in Obj-C is ‘AnyObject’ in Swift. You’ll need to use the “as” or “as?” operator to type-cast it to NSNumbe

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 supplied,