I want to log if the user pressed OK on my alertView
, but it's doing nothing... This is my check:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) { NSLog(@"user pressed OK"); }
}
Also it's in my @interface
:
@interface FirstViewController : UIViewController<UIWebViewDelegate, UIAlertViewDelegate>
And here's my alertView
:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
message:@"This is just a random message."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
Does anyone see the problem? I tried to do an NSLog
outside of the if buttonIndex
but that won't be logged too..
Thanks
Instead of delegate being nil,assign your delegate as self