Skip to content

Instantly share code, notes, and snippets.

@pratikshabhisikar
Created February 17, 2012 16:48
Show Gist options
  • Save pratikshabhisikar/1854318 to your computer and use it in GitHub Desktop.
Save pratikshabhisikar/1854318 to your computer and use it in GitHub Desktop.
Blocks
AppStoreConnectionHandler *appStoreConnection = [[AppStoreConnectionHandler alloc] init];
[appStoreConnection initiateConnectionForAppURL:[NSURL URLWithString:appURL] withCompletionBlock:^(NSURL *appURL, BOOL finished, NSError *error){
if (finished) {
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:appURL];
if (canOpenURL) {
[[UIApplication sharedApplication] openURL:appURL];
}else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"Application cannot open the URL" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}else {
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment