retrolux icon indicating copy to clipboard operation
retrolux copied to clipboard

Option NSNumber To Int Tranformer doesn't work

Open kyledstew opened this issue 6 years ago • 1 comments

Have the following transformer which doesn't work:

class OptionalNSNumberToIntTranformer: NestedTransformer {
    typealias TypeOfData = NSNumber?
    typealias TypeOfProperty = Int
    
    func setter(_ dataValue: NSNumber?, type: Any.Type) throws -> Int {
        return dataValue?.intValue ?? 0
    }
    
    func getter(_ propertyValue: Int) throws -> NSNumber? {
        return NSNumber(integerLiteral: propertyValue)
    }
}

kyledstew avatar Jul 31 '17 21:07 kyledstew