サブタイトルUNNotificationCategory
(UserNotifications)は、カテゴリ識別子としてハードコードされた文字列の代わりにenumを使用したいからです。 UNNotificationCategory
定義UNNotificationCategoryサブクラスinit発行
public convenience init(identifier: String, actions: [UNNotificationAction], intentIdentifiers: [String], options: UNNotificationCategoryOptions = [])
内部の1つの利便initが、私は私のサブクラスの初期化子を書くことができないですがあります。 スーパークラスのコンビニエンスinitを呼びたいので、私はサブクラス内でイニシャライザを指定できません。しかし、私の利便性のinitもcomplierエラーを投げている。ここで
は、コードは次のとおりです。
enum PushNotificationCategoryIdentifier:String {
}
convenience init(categoryIdentifier:PushNotificationCategoryIdentifier, actions:[UNNotificationAction], intentIdentifiers:[String], options: UNNotificationCategoryOptions) {
self.init(identifier: categoryIdentifier.rawValue, actions: actions, intentIdentifiers: intentIdentifiers, options: options)
}
これは、エラーが生じている。self.initは初期化子から
を返す前に、すべてのパスで呼び出されていない私は、このクラスが実装されているためであると思います(Objective-Cクラスは、便利な初期化子から指定された初期化子を呼び出す必要はありません)、彼らは便利な初期化子から指定された初期化子を呼び出していないかもしれません。
これで、初期化子を書きたい場合は、UNNotificationCategory
をサブクラス化できませんか?
何でinitを定義しますか?私はUNNotificationCategory変数を初期化することはできません。すべてがプロパティのみを取得するからです。 –