`NSValue` containing an `NSAffineTransform` from Swift

In trying to create a CIAffineTransform filter on MacOS X you are supposed to encode an NSAffineTransform using Objective-C code like:

[NSValue valueWithBytes:&xform
                           objCType:@encode(NSAffineTransform)];

But in Swift the Objective-C @encode directive does not exist in Swift.

How do you encode an NSAffineTransform into an NSValue in Swift so that it will be acceptable to Core Image?

I'm not sure what the best way to encode an NSAffineTransform into an NSValue is (maybe NSValue(nonretainedObject:)?), but there is actually a much simpler way for applying a transformation to an image using a CGAffineTransform:

let transformedImage = image.transformed(by: CGAffineTransform(...))

No need to use the CIAffineTransform filter.

`NSValue` containing an `NSAffineTransform` from Swift
 
 
Q