Method "Method ()" with Objective-C selector "Method" conflicts with getter for "Method" with the same Objective-C selector

Since upgrading to Xcode 6.3 I ran into this on one of my extensions ... for WKWebView .. In particular for these functions.

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

        })
    }
}

      

How can I fix them? It was fine in 6.2 .. a bit of a pain.

+3


source to share


1 answer


You will need to change the name of the function or override these functions if needed.



By the way, a conflicting name should always be avoided. I suggest using something like myURL

, myCanGoBack()

.

+1


source







All Articles