title: Edit outlet from different class - Cocoa
body: <p>I need to <strong><em>update the value</em></strong> of a NSProgressIndicator through a class different from the one where the outlet was defined.</p>
  
  <p>Es: </p>
  
  <ul>
  <li>In class A.h I define the outlet for the NSProgressIndicator and link it.</li>
  <li>In class A.m I have a method to update the doubleValue of the Indicator.</li>
  <li><strong>In class B</strong>.m I call, through an istance of class A, the method but <strong>nothing happens</strong>.</li>
  </ul>
  
  <p>Istead if i call the same method <strong>within class A</strong> it <strong>works fine</strong>.</p>
  
  <p>What am I missing ?</p>
  
  <pre><code>//REQUESTED CODE:
  //Class A (AppDelegate)
  A.m
  //Other stuff
  -(void)update_indicator:(double)value {
  //Method that updates the value of the indicator
  [progress_indicator setDoubleValue:(double)value];
  [progress_indicator setNeedsDisplay:YES];
  }
  
  //Class B (Drawing class - subclass of NSView)
  B.m
  - (void)drawRect:(NSRect)dirtyRect
  {
  [super drawRect:dirtyRect];
  //Create istance;
  A *istance = [[A alloc] init]; //Alloc class A and init it
  [A update_indicator:50.0];
  //Other code..
  }
  </code></pre>
  
  <p>The strange thing is that if I call <code>-(void)update_indicator:(double)value</code> within class A, where the outlet is defined, it works fine, if I call it from B it is being called but the progress bar is not showing.</p>