Uploaded image for project: 'Swift'
  1. Swift
  2. SR-1514

impossible to adopt WKScriptMessageHandler protocol

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Toolchain: Swift Development Snapshot 2016-05-09 (a)

      Description

      The WebKit WKScriptMessageHandler protocol has one required method, defined like this in Objective-C

      - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message;
      

      and like this in Swift

      public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage)
      

      Unfortunately, no matter how I write this method in my actual code, the compiler complains either that it doesn't match the argument names or that I'm not conforming to the protocol. Example:

      extension ViewController : WKScriptMessageHandler {
          func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
              
          }
      }
      

      That doesn't compile. It should.

      Moreover, no amount of playing with `@objc` overrides helps. I can't seem to find any workaround, so this project is currently out of action...

      I enclose a small test project for you to play with.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              mattneub Matt Neuburg
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: