title: How to set UILabel text from another class
body: <p>I have problem with <code>UILabel</code> . Here is two file's <code>ViewController</code> and <code>MainClass</code> 
  first is controller for nib file with <code>label1</code> outlet. Second file is a class with another label  <code>mainLabel</code> which contain text("Set from init method in MainClass"). I want set <code>mainLabel</code> to <code>label1</code> in <code>ViewController</code>.</p>
  
  <p>In <code>init</code> method of MainClass i set text for <code>mainLabel.text</code></p>
  
  <pre><code>mainLabel.text = @"Set from init method in MainClass";
  </code></pre>
  
  <p>and after that i call  <code>NSLog(@"%@",mainLabel.text);</code> but in console i have null</p>
  
  <pre><code>2011-12-14 10:31:31.048 ClassTask[1076:f803] (null)
  </code></pre>
  
  <p>and after then i call <code>label1 = newClass.mainLabel;</code> in <code>- (void)viewDidLoad</code> i have view with <code>label1</code> without text in my iPhone simulator.
  //  ViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "MainClass.h"
  @interface ViewController : UIViewController {
      UILabel *label1;    
      MainClass *newClass;
  }
  @property (nonatomic, retain) IBOutlet UILabel *testLabel;
  @end
  </code></pre>
  
  <p>//  ViewController.m</p>
  
  <pre><code>#import "ViewController.h"
  @implementation ViewController
  @synthesize label1;
  -(void) dealloc{
      [label1 release];
      [super dealloc];
  }
  #pragma mark - View lifecycle
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      newClass = [MainClass new];
      label1 = newClass.mainLabel;
  }
  @end
  </code></pre>
  
  <p>//  MainClass.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @interface MainClass : NSObject {
      UILabel *mainLabel;
  }
  @property (nonatomic, retain) IBOutlet UILabel *mainLabel;
  @end
  </code></pre>
  
  <p>//  MainClass.m</p>
  
  <pre><code>#import "MainClass.h" @implementation MainClass @synthesize mainLabel;
  -(id) init {
      if (self = [super init]) {
          mainLabel.text = @"Set from init method in MainClass";
          NSLog(@"%@",mainLabel.text);
      }
      return self; }
  -(void)dealloc {
      [mainLabel release];
      [super dealloc]; 
  } 
  @end
  </code></pre>