title: Where to programmatically declare images in Xcode
body: <p>I'm trying to build a timer app.  When the timer hits a certain number (say 5), I want an image to appear.  I have the timer working, and the image shows up, but when I declare an if statement to hide the image when the timer has not reached 5, the image shows up anyways.  Furthermore, when I declare the UIImageview at the bottom, Xcode reads me the error of "Local declaration of 'images' hides instance variable.<br>
  Thank you for any help you can offer!  I just started programming.</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  
  @implementation ViewController;
  
  -(IBAction)Start:(id)sender; {
      Timer = [NSTimer scheduledTimerWithTimeInterval:1 target: self selector:@selector(TimerCount) userInfo: nil repeats:YES];
  }
  
  -(void)TimerCount{
      CountNumber = CountNumber + 1;
      TimerDisplay.text=[NSString stringWithFormat:@"%i", CountNumber];
  
      if(CountNumber &lt; 6) {
          imagesx.hidden = YES;
      }
  
      if(CountNumber &gt; 6){
          imagesx.hidden = NO;
      }
  }
  
      -(IBAction)UIImage:(id) sender{
      self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage      imageNamed:@"Images.jpg"]];
      if (CountNumber &lt; 6){
          imagesx.hidden = YES;
        }
     }
  
    -(IBAction)Stop:(id)sender{
         [Timer invalidate];
        TimerDisplay.text=[NSString stringWithFormat:@"%i", CountNumber];
     }
  
    -(IBAction)Reset:(id)sender{
       CountNumber = 0;
      [Timer invalidate];
      CountNumber = 0;
      TimerDisplay.text=[NSString stringWithFormat:@"%i", CountNumber];
  
      Timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(TimerCount) userInfo:nil repeats:YES];
      [Timer invalidate];
      }
  
      -(IBAction)Restart:(id)sender{
      CountNumber = 0;
      TimerDisplay.text = [NSString stringWithFormat:@"%i", CountNumber];
      CountNumber = 0;
      Timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self    selector:@selector(TimerCount) userInfo:nil repeats: YES];
  
      if (CountNumber &lt; 6){
          imagesx.hidden = YES;
      }
  
      if (CountNumber &gt; 6){
          imagesx.hidden = NO;
      }
      }
  
  - (void)viewDidLoad{
      //create UIImage view programmatically
  
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
  
      UIImageView *imagesx =[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 200,     200)];
      imagesx.image=[UIImage imageNamed:@"images.jpeg"];
      [self.view addSubview:imagesx];
      }
  
      - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
      }
  
      @end
  </code></pre>
  
  <p>View Controller.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  int CountNumber;
  
  @interface ViewController : UIViewController
  {
      IBOutlet UILabel *TimerDisplay;
  
  UIImageView *imagesx;
  
  
  NSTimer *Timer;
  } 
  -(void)TimerCount;
  -(IBAction)Start:(id)sender;
  -(IBAction)Stop:(id)sender;
  -(IBAction)Restart:(id)sender;
  
  
  @property (strong, nonatomic) IBOutlet UILabel *FirstiPhoneapp;
  
  @property (strong, nonatomic) IBOutlet UILabel *ByJuliaTu;
  
  @property (strong, nonatomic) IBOutlet UIButton *Start;
  
  @property (strong, nonatomic) IBOutlet UIButton *Reset;
  
  @property (strong, nonatomic) IBOutlet UIButton *Terminate;
  
  @property (strong, nonatomic) IBOutlet UIButton *Restart;
  
  
  
  @end
  </code></pre>