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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -