title: Display a UIAlertView in NSObject Class
body: <p>I'm building a login system within my app that will be called several times. So instead of copying and pasting the code into several spots, I'm of course making an NSObject class so I can call the class when needed, instead.</p>
  
  <p>The login system will display a UIAlertView, and when "OK" is tapped, the system will attempt to log in. I can call the class and the UIAlertView will show, but I cannot tell which buttons are tapped. Here is my code:</p>
  
  <pre><code>//Calling the login system
  
  Login *login = [[Login alloc] init];
  </code></pre>
  
  <p><strong>Login.h</strong>:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface Login : NSObject &lt;UIAlertViewDelegate&gt; {
  
  }
  
  @end
  </code></pre>
  
  <p><strong>Login.m</strong>:</p>
  
  <pre><code>#import "Login.h"
  
  @implementation Login
  
  +(void)initialize {
  
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
  
      [alert show];
      [alert release];
  
      NSLog(@"Testing");
  
  }
  
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  {
  
      NSLog(@"Here");
  
      NSString *title = [alertView buttonTitleAtIndex:buttonIndex];  
  
      if([title isEqualToString:@"OK"]) {
  
          NSLog(@"Tapped");
  
      }
  
  }
  
  @end
  </code></pre>
  
  <p>For now, before I put UITextFields in the view, I just want to get the app to know which button was tapped. <code>Testing</code> appears in the log, but neither <code>Here</code> nor <code>Tapped</code> appear. Thanks!</p>