Skip to content
Browse files

Check if the delegate responds to the methods.

Otherwise you get a runtime error if a delegate was set but doesn't
implement them. Those methods are optional in the protocol.
  • Loading branch information...
1 parent e999b69 commit baf4ce22d2367d3a6b901d90105d9ded22b7e3a4 @fernandonf fernandonf committed Jan 14, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 Appirater.m
View
8 Appirater.m
@@ -385,7 +385,9 @@ + (void)rateApp {
NSNumber *appId = [NSNumber numberWithInteger:_appId.integerValue];
[storeViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:nil];
storeViewController.delegate = self.sharedInstance;
- [self.sharedInstance.delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
+ if ([self.sharedInstance.delegate respondsToSelector:@selector(appiraterWillPresentModalView:animated:)]) {
+ [self.sharedInstance.delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
+ }
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:storeViewController animated:_usesAnimation completion:^{
[self setModalOpen:YES];
//Temporarily use a black status bar to match the StoreKit view.
@@ -453,7 +455,9 @@ + (void)closeModal {
BOOL usedAnimation = _usesAnimation;
[self setModalOpen:NO];
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:_usesAnimation completion:^{
- [self.sharedInstance.delegate appiraterDidDismissModalView:(Appirater *)self animated:usedAnimation];
+ if ([self.sharedInstance.delegate respondsToSelector:@selector(appiraterDidDismissModalView:animated:)]) {
+ [self.sharedInstance.delegate appiraterDidDismissModalView:(Appirater *)self animated:usedAnimation];
+ }
}];
[self.class setStatusBarStyle:(UIStatusBarStyle)nil];
}

0 comments on commit baf4ce2

Please sign in to comment.
Something went wrong with that request. Please try again.