title: Assigned value is garbage or undefined logic error in XCode
body: <p>I am updating our iPhone app to iOs4 and I ran into an issue "Pass-by-argument in function call is undefined" in the code </p>
  
  <pre><code>for (i = 0; i &lt; self.numberOfSegments; i++) {
          [self setWidth:round(width[i]) forSegmentAtIndex:i];
  }
  </code></pre>
  
  <p>Which is fair enough, width[i] hasn't been initialized.  Updating the code (below) however gives me this new error, "Assigned value is garbage or undefined".  Reading up on this I think that segWidth retains its value as garbage - is that correct and if so how do I clear it?</p>
  
  <pre><code>for (i = 0; i &lt; self.numberOfSegments; i++) {
      float segWidth = (float)width[i];
      [self setWidth:round(segWidth) forSegmentAtIndex:i];
  }
  </code></pre>
  
  <p>------------- EDIT ------------------</p>
  
  <p>Thanks for the replies guys.  More information as follows;</p>
  
  <p>A genericised version of the method is shown below as someFunction. I have removed the ugly cast but still see the "Assigned Value is Garbage or undefined" logic error for the line <code>segWidth = width[i];</code>  </p>
  
  <p>I agree it appears the value width[i] doesn't have clear initialisation, I am unsure if it's my lack of understanding of basic Obj-c float types or if there is a logic flaw in my assignment syntax?</p>
  
  <pre><code>- (void)someFunction
  {
      unsigned int n = self.numberOfSegments;
      float width[n];
  
      for (i = 0; i &lt; n; i++) {
         width[i] = someFloatValue;
      }
  
      ...    
  
      for (i = 0; i &lt; self.numberOfSegments; i++) {
         float segWidth = 0.0;
         segWidth = width[i];
  
         [self setWidth:round(segWidth) forSegmentAtIndex:i];
      }
  
  }
  </code></pre>
  
  <p>Definition of setWidth is:</p>
  
  <pre><code>- (void)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment;         // set to 0.0 width to autosize. default is 0.0
  </code></pre>