xcode - Change UILabel from appDelegate -


i want stuff appdelegate in xcode. 1 of these things change uilabel.

viewcontroller *viewcontroller = [[uistoryboard storyboardwithname:@"main_iphone" bundle:nil]        instantiateviewcontrollerwithidentifier:@"id"];   viewcontroller.label.text = @"heeej"; 

i told trick. doesn't work. label doesn't change. know problem is?

there several problems:

  1. don't in appdelegate except loading window initial view controllers (if needed).
  2. you instantiating new view controller in first line. assume have view controller , want change label in view controller. need reference view controller , use reference send messages it.
  3. the label should not property of view controller. should try follow design pattern model-view-controller or pattern model-view-viewmodel. ask preferred search engine if don't know.
  4. id identifier in objective-c bad idea because used object type.

edit: don't need reference change property in view controller. use notifications update label. system sends notification name uiapplicationwillenterforgroundnotification' (see [here][1]). add view controller observer the[nsnotificationcenter defaultcenter]` name , react on notification. read apple documentation if don't know talking about.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -