xcode - Firing a function whenever static variable value changed -
i'm developing iphone apps using swift communicate device via bluetooth. question want fire function on class(change display value) whenever variable received new data corebluetooth. can helps!
wei
implement delegate perform it
write protocol
protocol valuechangeddelegate { func valuechanged(nvalue:int) }
and implement protocol in view controller want new value
class yourcustomclass: valuechangeddelegate { func valuechanged(nvalue:int) { print("value changed") } }
then implement delegate , set delegate self , call method when value changes, classes implement protocol receive new value
you can refer delegate in swift-language
Comments
Post a Comment