title: remove a programmatically added UIImageView
body: <p>i'm making a program that has 2 Buttons in main view ; </p>
  
  <p>one is called show and other one is hide,</p>
  
  <p>when user presses show butoon an imageview gets added to screen</p>
  
  <p>code :</p>
  
  <pre><code>-(IBAction)show{
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 155, 155)];
    img.image = [UIImage imageNamed:@"icon.png"];
    [self.view addSubview:img];
  }
  </code></pre>
  
  <p>and when user presses the hide button , i want app to hide the image that  has been just added (img)</p>
  
  <p>but...</p>
  
  <p>when i use</p>
  
  <pre><code>-(IBAction)add{
    [img removeFromSuperView];
  }
  </code></pre>
  
  <p>Xcode says "img Undecleared"</p>
  
  <p>edit : Some said define the object as a public object (@property) but problem is that  the imageview gets added just once. but i wanted it to add new imageview every time user presses the Show button,</p>
  
  <p>so i used the [[self subviews]objectAtIndex:xx]removeFromSuperview] method to solve the problem</p>