arashpayan / appirater

A utility that reminds your iPhone app's users to review the app.

Home Page:http://arashpayan.com/blog/2009/09/07/presenting-appirater/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with [UIAlertController dismissWithClickedButtonIndex:animated:]: unrecognized selector sent to instance [Fix provided]

nickbit opened this issue · comments

Hi Arash,

Crash occurs in Appirater.m:570

- (void)hideRatingAlert {
	if ([self isRatingAlertVisible]) {
		if (_debug)
			NSLog(@"APPIRATER Hiding Alert");
		[self.ratingAlert dismissWithClickedButtonIndex:-1 animated:NO];
	}	
}

Reason is that dismissWithClickedButtonIndex:animated is valid for UIAlertView but not for UIAlertController.

Here is a fix:

- (void)hideRatingAlert {
	if ([self isRatingAlertVisible]) {
		if (_debug)
			NSLog(@"APPIRATER Hiding Alert");
	        if ([self.ratingAlert respondsToSelector:@selector(dismissWithClickedButtonIndex:animated:)]) {
        	    [self.ratingAlert dismissWithClickedButtonIndex:-1 animated:NO];
	        } else {
        	    [self.ratingAlert dismissViewControllerAnimated:NO completion:nil];
	        }
	}	
}

I've received crash alerts for the same issue. Please fix.

Nickbit, do you have a fork for this? We really need to get this fix out to users right away as its affecting a ton of users on apps.

Thank you for the diagnosis and solution @nickbit. @jamescahall, I'll be releasing an update with this fix in an hour or two.

I released this in 2.3.1.