Posted By

code4mac on 09/07/12


Tagged

url safari open ibaction


Versions (?)

(ibaction) Open URL in safari


 / Published in: Objective C
 

simple snippet to open url with an ibaction in safari

  1. - (IBAction)LauchURLAction:(id)sender
  2. {
  3.  
  4. NSLog(@"***[STARTING] - open URL in Safari ");
  5. [self launchURL:@"http://www.someurl.com"];
  6. }
  7.  
  8.  
  9.  
  10. - (void)launchURL:(NSString *) urlToLaunch
  11. {
  12. NSLog(@"***[STARTING] - launch url ");
  13. NSString *urlToOpen = [NSString stringWithFormat:urlToLaunch];
  14. urlToOpen = [urlToOpen stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
  15. NSURL *url = [NSURL URLWithString:urlToOpen];
  16. if (![[UIApplication sharedApplication] openURL:url])
  17. NSLog(@"%@%@", @"Failed ton open url:",[url description]);
  18. }

Report this snippet  

You need to login to post a comment.