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...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.