Here is how I show UIAlertView and the delegate clickedButtonAtIndex -
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"title"
message: @"message"
delegate: self
cancelButtonTitle: @"Cancel"
otherButtonTitles: @"Continue", nil];
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
//something
}
This piece of code works perfectly without ARC. But with ARC it throws this error - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance 0x859d790'
Any ideas on why the delegate is throwing this error?
Your delegate has been dealloc'd. Double-check your code to make sure the object that is showing the alert and setting itself as the delegate is being retained somehow (ie: something in your app has a strong reference to it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With