What is this code?

Hi there,


What can this code do "getPagesWithCompletionHandler"? On this developer page:

https://developer.apple.com/documentation/safariservices/sfsafaritab/1639496-getpageswithcompletionhandler


Can anybody provide a working sample code in swift, of his function (example when I click on the toolbar button)?

Is that the code to 'get' all the open Safari tabs?


override func toolbarItemClicked(in window: SFSafariWindow) {
  page.getPagesWithCompletionHandler(completionHandler: {
                    each in
                    each!.dispatchMessageToScript(withName: "runthatscript")
                    print("for each tab!")
                })
}


Kind Regards,

Stefan