I want the cancel button of my UIAlertView to launch the app store so that my app can be updated. I can get the app to launch the app store, but I want it to launch only when the cancel button of my UIAlertView is pressed. The way I have it now, I'm given this error when I press the cancel button:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance 0x1651bd90'
Here's the code where I initialize and display the UIAlertView:
NSString* updateString = @"Please update the app! Thank you!";
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Please Update" message:updateString delegate:self cancelButtonTitle:@"Update Now" otherButtonTitles:nil];
[alert show];
Here's the function that's supposed to handle the cancel button being pressed:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]];
}
I've written in the containing object's header file that it follows the UIAlertViewDelegate protocol.
What am I doing wrong here?