それは私だけですか、またはNotificationCenter
はスウィフト3の熱い混乱になったのですか? :)私は次のセットアップがあります。私の最初のビューコントローラで通知センタークラッシュスウィフト3
//Yonder.swift
extension Notification.Name {
static let preferenceNotification = Notification.Name("preferencesChanged")
}
//I fire the notification elsewhere like this:
NotificationCenter.default.post(name: .preferenceNotification, object: nil)
を、これは素晴らしい作品:
//View Controller A <-- Success!
NotificationCenter.default.addObserver(self, selector: #selector(refreshData), name: .preferenceNotification, object: nil)
func refreshData(){
//...
}
しかし、このビューコントローラ:
//View Controller B <-- Crash :(
NotificationCenter.default.addObserver(self, selector: #selector(loadEntries(search:)), name: .preferenceNotification, object: nil)
func loadEntries(search:String?){
//...
}
...でクラッシュ:
[NSConcreteNotification length]:認識できないセレクタ例として
私の知る限り、私の観察者は正しく設定されています。私が間違っていることは何か考えていますか?
可能な複製(http://stackoverflow.com/questions/38310080/nsnotifications-in-swift-3) –