I am trying to make that when the user press Facebook button, it opens the Facebook application, or in browser.
Import code:
import Foundation
Extension code:
extension UIApplication {
class func tryURL(urls: [String]) {
let application = UIApplication.sharedApplication()
for url in urls {
if application.canOpenURL(NSURL(string: url)!) {
application.openURL(NSURL(string: url)!)
return
}
}
}
}
Function code:
func fimageTapped()
{
UIApplication.tryURL([
"fb://profile/1357163924", // App
"http://www.facebook.com/1357163924" // Website if app fails
])
}
I get error at line:
class func tryURL(urls: [String]) {
Error message:
Invalid redeclaration of "tryURL"
This is where i found the code from: Xcode swift link to facebook page
Anyone has any idea what is wrong here?