Saturday, 17 August 2013

Method didDismissWithButtonIndex not firing from within singleton class

Method didDismissWithButtonIndex not firing from within singleton class

I'm trying to handle the dismissal event for a UIAlertView. However
didDismissWithButtonIndex never gets called. Below is my code from the
singleton class in which I am spawning the alert. Can someone spot what
I've done wrong?
MySingleton.h
@interface BMAppUser : NSObject <UIAlertViewDelegate> {
}
+ (id)sharedInstance;
MySingleton.m
+ (id) sharedInstance {
static BMAppUser *sharedInstance = nil;
@synchronized(self) {
if (sharedInstance==nil) {
sharedInstance = [[super allocWithZone:NULL] init];
}
}
return sharedInstance;
}
-(void)promptToSetLanguagePreferences {
// Create a new alert object and set initial values.
NSString *message = [NSString stringWithFormat:@"Please set your language
preference settings. Click OK to go there now."];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Language
Preferences Not Set"
message:message
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
// Display the alert to the user
[alert show];
}
-(void)alertView:(UIAlertView
*)didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"THIS METHOD NEVER GETS CALLED!!!!!!!");
if(buttonIndex==0){
NSLog(@"userclickedCancel");
}
if(buttonIndex==1){
NSLog(@"userclickedOK");
}
}

No comments:

Post a Comment