title: iOS - Accessing variable declared in method A from method B in the same class
body: <p>How do you do this? See my code example below:</p>
  
  <pre><code>- (void)methodA {
      ...
      UILabel *label1 = [[UILabel alloc] initWithFrame:frame];
      ...
  }
  
  - (void)methodB {
  
      label1.text = "Label 1";
  }
  </code></pre>
  
  <p><strong>EDIT:</strong> Why I'm wondering this is because I can not set an instance variable to the class. Because I will not <strong>know</strong> when the class loads how many <code>UILabel</code>s I will need. It will be a different amount each time the class is loaded. So I will need to dynamically create these UILabels in a method and then be able to access these labels throughout the rest of the class in a convenient way.</p>