ios - Connect two labels to one outlet -


now understand question has been asked before, answers unsatisfactory. issue have view controller view , stuff in including label. added bunch of code , i'm expanding on it. have issue i've decided add uiview interface , has label , label going function label have in first uiview. problem don't want have go in view controller method , add line of code each time manipulate first label. there anyway can link label initial iboutlet have set first label? or have go in code , add line of code everytime manipulate first label?

basically simple answer no. whether use outlets or outlet collection or tags or whatever, have one reference in code one label in interface, , another reference in code another reference in interface. can compress mode of expression cycle readily through references (as suggested in different answer), basic fact inescapable that, ultimately, way "talk to" label through 1 reference points that label , label alone.

the way of getting around not use direct references @ all. example, single message can sent multiple recipients using nsnotification. have 2 instances of uilabel subclass of own, , "shout" both instances simultaneously posting notification view controller - notification automatically passed on both labels, because have arranged beforehand them register it.

similarly, alternative use key-value observing change in view controller automatically propagated both labels automatically because "observe" change, meaning sent notifications - inverted form of nsnotification. (if mac os x, make simpler, safer version of arrangement using "bindings".)

however, cannot recommend approach. truth still live in excruciatingly primitive world of text-based programming, 1 line @ time, 1 command @ time, 1 reference @ time, , must bite bullet , on it.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -