[英]Swift - Method '*()' with Objective-C selector '*' conflicts with getter for '*' from superclass 'UIView' with the same Objective-C selector
[英]Method 'Method()' with Objective-C selector 'Method' conflicts with getter for 'Method' with the same Objective-C Selector
自从更新到Xcode 6.3后,我在我的一个扩展中遇到了这个...对于WKWebView ..特别是在这些函数上。
import UIKit
import WebKit
extension WKWebView: MyWebViewProvider {
// Method 'URL()' with Objective-C selector 'URL' conflicts with getter for 'URL' with the same Objective-C Selector
func URL() -> NSURL? {
return self.URL
}
// Method 'canGoBack()' with Objective-C selector 'canGoBack' conflicts with getter for 'canGoBack' with the same Objective-C Selector
func canGoBack() -> Bool {
return self.canGoBack
}
// Method 'canGoForward()' with Objective-C selector 'canGoForward' conflicts with getter for 'canGoFoard' with the same Objective-C Selector
func canGoForward() -> Bool {
return self.canGoForward
}
// Method 'evaluateJavaScript(_:completionHandler:)' with Objective-C selector 'evaluateJavaScript:completionHandler:' conflicts with previous declaration with the same Objective-C selector
func evaluateJavaScript(javascriptString: String!, completionHandler: (AnyObject, NSError) -> ()) {
self.evaluateJavaScript(javascriptString, completionHandler: { (AnyObject, NSError) -> Void in
})
}
}
我该如何解决这些问题? 它有点痛苦。
您必须更改函数名称,或者如果这是您想要的那些,则覆盖这些函数。
顺便说一句,应始终避免名称冲突。 我建议使用像myURL
, myCanGoBack()
这样的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.