Function used in selector in iOS Swift can only be in the same file? -
i have created time activate on view controller. needs phone call selector, , selector, calling function.
when function in view controller file, works. if set function in swift file created in app, not find selector , error during runtime.
is possible set functions in swift in different files or not?
@ibaction func startnotificationtimer(sender: anyobject) { timer = nstimer.scheduledtimerwithtimeinterval(10, target: self, selector: "update_start", userinfo: nil, repeats: true) timerstatus.text = "started" }
"update_start" in different file.
thanks help
it doesn't matter file update_start
method in, matter method in view controller class. if define in file other 1 class declared, you'll need define method in extension on class.
also, nstimer
selectors should end colon (update_start:
), because take single parameter (the timer) when called.
function swift ios8
No comments:
Post a Comment