Xcode を 8.0 (8A218a) にアップグレードしたばかりで、Swift 2.3 のプロジェクトを Swift 3.0 に変換しています。現在残っている唯一の問題は、次のエラーです。
「ibtool 実行中の例外: UTIToIconTransformer という名前の値トランスフォーマーが見つかりません」
は次のUTIToIconTransformer
ように定義されます。
@objc(UTIToIconTransformer) class UTIToIconTransformer : ValueTransformer {
// ...
}
Swift 2.3 のとき、コードは正常に機能しました。この値トランスフォーマーを使用するバインディングは、次のように設定されます。
このバインドを削除すると、アプリが実行され、行のタイトルが正しく表示されます。
ここで、ここで StackOverflowで、ここで NShipsterで提案されているようNSValueTransformer.setValueTransformer()
に、アプリデリゲートの+initialize()
、applicationDidFinishLaunching
および値トランスフォーマーので呼び出してみました (ただし、「通常、シングルトンインスタンスは +initialize に登録されます。値変換サブクラスのメソッドであるため、それ以上のセットアップなしで使用できます。" は Apple のドキュメントに準拠しています)、すべて成功しませんでした。+initialize()
アップルのドキュメントでは、それは言う
Value transformers are typically registered by an application’s delegate
class, in response to receiving a initialize: class message. This allows
registration to occur early in the application startup process, providing
access to the value transformers as nib files load.
Availability in Interface Builder
Your NSValueTransformer subclasses are not automatically listed in the
Interface Builder bindings inspector. When inspecting a binding you can enter
the name that the value transformer is registered with, but the functionality
will not be present in Interface Builder’s test mode. When your application
is compiled and run the transformer will be used.
しかし、に登録しても役に立ちませんでしたAppDelegate
。override class func initialize()
Xcode 7 と Swift 2.3 では、登録なしでも機能しました。