我到处寻找答案,但没有一个答案似乎适合我的问题。
我有一个switch语句,只要情况不同就会引用一个函数:
switch wall["ExposureOneType"] as! String {
case "Twitter":
cell.exposureButtonOne.addTarget(self, action: #selector(self.openThis(urlStr:"https://twitter.com/\(String(describing: wall["ExposureOne"]))")), for: UIControlEvents.touchUpInside)
case "Instagram":
cell.exposureButtonOne.addTarget(self, action: #selector(openThis(urlStr:"https://www.instagram.com/\(String(describing: wall["ExposureOne"]))")), for: UIControlEvents.touchUpInside)
case "Youtube":
cell.exposureButtonOne.addTarget(self, action: #selector(openThis(urlStr:"https://www.youtube.com/user/\(String(describing: wall["ExposureOne"]))")), for: UIControlEvents.touchUpInside)
case "Facebook":
cell.exposureButtonOne.addTarget(self, action: #selector(openThis(urlStr:"https://www.facebook.com/\(String(describing: wall["ExposureOne"]))")), for: UIControlEvents.touchUpInside)
case "Snapchat":
cell.exposureButtonOne.isEnabled = false
default:
cell.exposureButtonOne.isEnabled = false
}
openThis()函数是:
func openThis(urlStr:String!) {
if let url = URL(string: urlStr) {
UIApplication.shared.open(url as URL, options: [:], completionHandler: nil)
}
}
但是我收到了标题中的错误。有什么理由吗?任何解决方法?所有帮助将不胜感激!