Following code works perfectly in swift 3.x but not in swift 4.
let selector = "managerDidDetectedStation:"
let observer = <UIViewController subclass object>
let station = <Station Object>
if observer.responds(to: Selector(selector) {
observer.perform(Selector(selector), with: station)
}
observer.responds(to: Selector(selector)
always returns false. Does anybody aware of any change in this api in swift4?
You need to add @objcMembers at top of observer
class
For Ex. if observer
is a object of XYZClass
class then write
@objcMembers
class XYZClass : NSObject
{
// Your Stuff
}
OR
Another way is to put @objc
to start of your method like below.
@objc func managerDidDetectedStation...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With