BEGINNER ALERT! Please talk to me like I'm a 5-year-old because I am new to this platform and language. I will be grateful and unoffended.
I have the following code in my Xcode project to open a website in the native browser from a button on the app home page:
@IBAction func faceURL(_ sender: Any) {
NSURL *spotiURL = [NSURL URLWithString:@"https://www.facebook.com"];
[[UIApplication sharedApplication] openURL:faceURL options:@{} completionHandler:^(BOOL success) {
if (success){
NSLog(@"Opened url");
}
}];
}
NSURL *spotiURL = [NSURL URLWithString:@"https://www.facebook.com"];
Expected "," separator Consecutive statements on a line must be separated by ";"
;
@
It looks like you're trying to use Objective C code in a Swift method. If your project is written in Swift then this is (probably) the code you need:
@IBAction func faceURL(_ sender: Any) {
if let facebookURL = URL(string: "https://www.facebook.com")
{
UIApplication.shared.openURL(facebookURL) // the open method you were using doesn't exist in Swift
}
}
I'd suggest you work through a few tutorials to learn the basics of iOS development.