Reputation: 393
I have a url which i have in NSString urlone which is coming from xml. but i run application it gives excess bad error
// urlone contains http://www.forasinvest.com/v2/index.php
NSString*myurl=urlone;
NSURL *url = [NSURL URLWithString:myurl];
[[UIApplication sharedApplication] openURL:url];
Upvotes: 38
Views: 39527
Reputation: 613
NSString *pURL = @"xyz.cpm";
if( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:pURL]])
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:pURL]];
Upvotes: 15
Reputation: 1170
The most updated code till date, working with iOS 11.3 and if you're not looking for a deprecated warning, use this single line of code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"https://example.com"] options:@{} completionHandler:nil];
Upvotes: 12
Reputation: 3709
i think it should work fine, ok just copy paste the following for testing simply
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.forasinvest.com/v2/index.php"]];
Upvotes: 77