I'm trying to use a ValueTransformer
(né NSValueTransformer
) in Swift that is being used by the first window that my application opens. Value transformers need to be registered with ValueTransformer.registerValueTransformer(_:forName:)
before they can be queried by the user interface runtime.
The documentation for NSValueTransformer
recommends registering value transformers in +[AppDelegate initialize]
. However, Swift doesn't allow you to override +initialize
. I tried to register from applicationWillFinishLaunching(_)
and applicationDidFinishLaunching(_)
, but they both happen too late and my window doesn't get filled because the runtime can't find the value transformer.
Where should I register my value transformer?