How to print class name in Swift


Gerriet M. Denkmann
 

This works (prints either null, NSString or NSNumber)

- (id)transformedValue:(id)value
{
NSLog(@"%s value %@ %@",__FUNCTION__, [value class], value);

}

But my Swift version:

override func transformedValue(_ value: Any?) -> Any?
{
print(“value \(String(describing: type(of: value))) \(String(describing:value))")

}

just prints:
value Optional<Any> Optional(33)

I do not want to know what the compiler things about value, I want to know what value is at run-time.

How can this be done?

Gerriet.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.