Im trying to pass the UIView() though the NSTimer.scheduledTimerWithTimeInterval()
here is a code:
_ = NSTimer.scheduledTimerWithTimeInterval((Getsome("Adur") as! Double * 3.0), target: self, selector: "StartAnim", userInfo: ["vie" : bgview as UIView], repeats: true)
func StartAnim(timer: NSTimer)
{
let userInfo = timer.userInfo as! Dictionary<String, UIView>
GR(userInfo["vie"]!)
}
The NSTimer action is happening in another internal function
the GR(vie: UIVIew) is privat func
all those functions are in seperate UIVIewController extention file.
And the error im getting:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[App.VC StartAnim]: unrecognized selector sent to instance
If StartAdmin takes a parameter, it should be called like:
StartAdmin:
Additionally, if you're using Swift 2.2, you should use the new #selector method:
#selector(self.StartAdmin(_:))
If the function is private, you will need to add
@objc
Before it's declaration as well, example
@objc private func someFunc(parameter: AnyObject) { }
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.