title: Ios - syntax error trying to add a listener to the textview
body: <p>I have a textView for which the submit button gets overlapped by the keyboard, so I am trying to add a listener for when a user taps anywhere else on the screen to get rid of the keyboard.</p>
  
  <p>I am trying to add code like this to my controller:</p>
  
  <pre><code>-(void)touchesBegan:(NSSet *) touches withEvent:(UIEvent *)event
  {
      [textView resignFirstResponder];
  }
  </code></pre>
  
  <p>but this gives a syntax error that the textView is not declared.  But that is confusing because I added the textView to the screen already.  </p>
  
  <p>Here is the code: </p>
  
  <pre><code>#import "FeedbackController.h"
  
  @interface FeedbackController ()
  
  @end
  
  @implementation FeedbackController
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  }
  
  
  
  - (void)viewDidUnload
  {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
  }
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
  }
  
  -(void)touchesBegan:(NSSet *) touches withEvent:(UIEvent *)event
  {
      [textView resignFirstResponder];
  }
  
  - (IBAction)submitFeedback:(id)sender {
      NSLog(@"This is a test hello");
  }
  @end
  </code></pre>
  
  <p>And here is how the screen looks like: 
  <img src="https://i.stack.imgur.com/GDTUD.jpg" alt="enter image description here"></p>
  
  <p>Any idea how I can try to reference the textView correctly? and how I can make the keyboard disappear when the other parts of the screen are touched?</p>
  
  <p>Thanks!</p>