title: iPhone - Unrecognized Selector, "may not respond to addTarget"
body: <p>I'm working on a basic iPhone app to test some events, and I'm running into an error that I can't understand or find any answers for. I'm not using IB at all (aside from the MainWindow.xib it creates).</p>
  
  <p>Right now it's about as basic as it could be.</p>
  
  <p>mainAppDelegate.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "mainViewController.h"
  
  @interface mainAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {
      UIWindow *window;
      mainViewController *viewController;
  }
  
  @property (nonatomic, retain) IBOutlet UIWindow *window;
  @property (nonatomic, retain) mainViewController *viewController;
  
  @end
  </code></pre>
  
  <p>mainAppDelegate.m</p>
  
  <pre><code>#import "mainAppDelegate.h"
  
  @implementation mainAppDelegate
  
  @synthesize window;
  @synthesize viewController;
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
  
      self.viewController = [[mainViewController alloc] init];
      [window addSubview:viewController.view];
      [window makeKeyAndVisible];
  
      return YES;
  }
  
  - (void)dealloc {
      [viewController release];
      [window release];
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>mainViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface mainViewController : UIViewController {
  
  }
  
  - (void)showMenu;
  
  @end
  </code></pre>
  
  <p>mainViewController.m</p>
  
  <pre><code>#import "mainViewController.h"
  
  @implementation mainViewController
  
  - (void)loadView {
      UIScrollView *mainView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
      mainView.scrollEnabled = YES;
      self.view = mainView;    
      self.view.backgroundColor = [UIColor grayColor];
  
      [self.view setUserInteractionEnabled:YES];
      [self.view addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchDown];
  
      [mainView release];
  }
  
  - (void)showMenu {
      NSLog(@"Show Menu");
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
  }
  
  - (void)viewDidUnload {
      [super viewDidUnload];
  }
  
  - (void)dealloc {
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>Now, I get a warning on this line:</p>
  
  <pre><code>[self.view addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchDown];
  </code></pre>
  
  <p>that says 'UIView may not respond to '-addTarget:action:forControlEvents:'. And this doesn't make sense, because a UIView subclass can certainly respond to addTarget, and I'm calling it  on self.view, which must exist because I don't release it until the end of loadView. (and even then it should be retained by the controller)</p>
  
  <p>Looking at a trace shows that the actual error is 
  -[UIScrollView addTarget:action:forControlEvents:]: unrecognized selector sent to instance 0x5f11490</p>
  
  <p>So it looks like it's a problem with the selector itself, but I see nothing wrong with my selector! </p>
  
  <p>I'm pretty baffled by this and any help would be great.</p>