Documentation Archive Developer
Search

WebKit Changes for Swift

WebKit

Declaration
From
class WKBackForwardList : NSObject {
    var currentItem: WKBackForwardListItem? { get }
    var backItem: WKBackForwardListItem? { get }
    var forwardItem: WKBackForwardListItem? { get }
    func itemAtIndex(_ index: Int) -> WKBackForwardListItem?
    var backList: [AnyObject] { get }
    var forwardList: [AnyObject] { get }
}
To
class WKBackForwardList : NSObject {
    var currentItem: WKBackForwardListItem? { get }
    var backItem: WKBackForwardListItem? { get }
    var forwardItem: WKBackForwardListItem? { get }
    func itemAtIndex(_ index: Int) -> WKBackForwardListItem?
    var backList: [WKBackForwardListItem] { get }
    var forwardList: [WKBackForwardListItem] { get }
}

Declaration
From
var backList: [AnyObject] { get }
To
var backList: [WKBackForwardListItem] { get }

Declaration
From
var forwardList: [AnyObject] { get }
To
var forwardList: [WKBackForwardListItem] { get }

DeclarationProtocolsRaw Value Type
From
enum WKErrorCode : Int {
    case Unknown
    case WebContentProcessTerminated
    case WebViewInvalidated
    case JavaScriptExceptionOccurred
}
Equatable, Hashable, RawRepresentable--
To
enum WKErrorCode : Int {
    case Unknown
    case WebContentProcessTerminated
    case WebViewInvalidated
    case JavaScriptExceptionOccurred
    case JavaScriptResultTypeIsUnsupported
}
extension WKErrorCode : Hashable, Equatable, __BridgedNSError, ErrorType, RawRepresentable, _ObjectiveCBridgeableErrorType, _BridgedNSError {
}
extension WKErrorCode : Hashable, Equatable, __BridgedNSError, ErrorType, RawRepresentable, _ObjectiveCBridgeableErrorType, _BridgedNSError {
}
Equatable, ErrorType, Hashable, RawRepresentableInt

Modified WKFrameInfo
Declaration
From
class WKFrameInfo : NSObject, NSCopying {
    var mainFrame: Bool { get }
    @NSCopying var request: NSURLRequest { get }
}
To
class WKFrameInfo : NSObject, NSCopying {
    var mainFrame: Bool { get }
    @NSCopying var request: NSURLRequest { get }
    var securityOrigin: WKSecurityOrigin { get }
}

Declaration
From
class WKNavigationAction : NSObject {
    @NSCopying var sourceFrame: WKFrameInfo? { get }
    @NSCopying var targetFrame: WKFrameInfo? { get }
    var navigationType: WKNavigationType { get }
    @NSCopying var request: NSURLRequest { get }
}
To
class WKNavigationAction : NSObject {
    @NSCopying var sourceFrame: WKFrameInfo { get }
    @NSCopying var targetFrame: WKFrameInfo? { get }
    var navigationType: WKNavigationType { get }
    @NSCopying var request: NSURLRequest { get }
}

Declaration
From
@NSCopying var sourceFrame: WKFrameInfo? { get }
To
@NSCopying var sourceFrame: WKFrameInfo { get }

Raw Value Type
From--
ToInt

Declaration
From
protocol WKNavigationDelegate : NSObjectProtocol {
    optional func webView(_ webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler decisionHandler: (WKNavigationActionPolicy) -> Void)
    optional func webView(_ webView: WKWebView, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler decisionHandler: (WKNavigationResponsePolicy) -> Void)
    optional func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError)
    optional func webView(_ webView: WKWebView, didCommitNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFinishNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFailNavigation navigation: WKNavigation!, withError error: NSError)
    optional func webView(_ webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential!) -> Void)
}
To
protocol WKNavigationDelegate : NSObjectProtocol {
    optional func webView(_ webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler decisionHandler: (WKNavigationActionPolicy) -> Void)
    optional func webView(_ webView: WKWebView, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler decisionHandler: (WKNavigationResponsePolicy) -> Void)
    optional func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError)
    optional func webView(_ webView: WKWebView, didCommitNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFinishNavigation navigation: WKNavigation!)
    optional func webView(_ webView: WKWebView, didFailNavigation navigation: WKNavigation!, withError error: NSError)
    optional func webView(_ webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void)
    optional func webViewWebContentProcessDidTerminate(_ webView: WKWebView)
}

Declaration
From
optional func webView(_ webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential!) -> Void)
To
optional func webView(_ webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void)

Raw Value Type
From--
ToInt

Raw Value Type
From--
ToInt

Raw Value Type
From--
ToInt

Modified WKUIDelegate
Declaration
From
protocol WKUIDelegate : NSObjectProtocol {
    optional func webView(_ webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures windowFeatures: WKWindowFeatures) -> WKWebView?
    optional func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: () -> Void)
    optional func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (Bool) -> Void)
    optional func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (String!) -> Void)
}
To
protocol WKUIDelegate : NSObjectProtocol {
    optional func webView(_ webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures windowFeatures: WKWindowFeatures) -> WKWebView?
    optional func webViewDidClose(_ webView: WKWebView)
    optional func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: () -> Void)
    optional func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (Bool) -> Void)
    optional func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (String?) -> Void)
}

Declaration
From
optional func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (String!) -> Void)
To
optional func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler completionHandler: (String?) -> Void)

Declaration
From
class WKUserContentController : NSObject {
    var userScripts: [AnyObject] { get }
    func addUserScript(_ userScript: WKUserScript)
    func removeAllUserScripts()
    func addScriptMessageHandler(_ scriptMessageHandler: WKScriptMessageHandler, name name: String)
    func removeScriptMessageHandlerForName(_ name: String)
}
To
class WKUserContentController : NSObject {
    var userScripts: [WKUserScript] { get }
    func addUserScript(_ userScript: WKUserScript)
    func removeAllUserScripts()
    func addScriptMessageHandler(_ scriptMessageHandler: WKScriptMessageHandler, name name: String)
    func removeScriptMessageHandlerForName(_ name: String)
}

Declaration
From
var userScripts: [AnyObject] { get }
To
var userScripts: [WKUserScript] { get }

Raw Value Type
From--
ToInt

Modified WKWebView
Declaration
From
class WKWebView : UIView {
    @NSCopying var configuration: WKWebViewConfiguration { get }
    weak var navigationDelegate: WKNavigationDelegate?
    weak var UIDelegate: WKUIDelegate?
    var backForwardList: WKBackForwardList { get }
    init(frame frame: CGRect, configuration configuration: WKWebViewConfiguration)
    convenience init!(coder coder: NSCoder!)
    func loadRequest(_ request: NSURLRequest) -> WKNavigation?
    func loadHTMLString(_ string: String, baseURL baseURL: NSURL?) -> WKNavigation?
    func goToBackForwardListItem(_ item: WKBackForwardListItem) -> WKNavigation?
    var title: String? { get }
    @NSCopying var URL: NSURL? { get }
    var loading: Bool { get }
    var estimatedProgress: Double { get }
    var hasOnlySecureContent: Bool { get }
    var canGoBack: Bool { get }
    var canGoForward: Bool { get }
    func goBack() -> WKNavigation?
    func goForward() -> WKNavigation?
    func reload() -> WKNavigation?
    func reloadFromOrigin() -> WKNavigation?
    func stopLoading()
    func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject!, NSError!) -> Void)?)
    var allowsBackForwardNavigationGestures: Bool
    var scrollView: UIScrollView { get }
}
To
class WKWebView : UIView {
    @NSCopying var configuration: WKWebViewConfiguration { get }
    weak var navigationDelegate: WKNavigationDelegate?
    weak var UIDelegate: WKUIDelegate?
    var backForwardList: WKBackForwardList { get }
    init(frame frame: CGRect, configuration configuration: WKWebViewConfiguration)
    convenience init(coder coder: NSCoder)
    func loadRequest(_ request: NSURLRequest) -> WKNavigation?
    func loadFileURL(_ URL: NSURL, allowingReadAccessToURL readAccessURL: NSURL) -> WKNavigation?
    func loadHTMLString(_ string: String, baseURL baseURL: NSURL?) -> WKNavigation?
    func loadData(_ data: NSData, MIMEType MIMEType: String, characterEncodingName characterEncodingName: String, baseURL baseURL: NSURL) -> WKNavigation?
    func goToBackForwardListItem(_ item: WKBackForwardListItem) -> WKNavigation?
    var title: String? { get }
    @NSCopying var URL: NSURL? { get }
    var loading: Bool { get }
    var estimatedProgress: Double { get }
    var hasOnlySecureContent: Bool { get }
    var certificateChain: [AnyObject] { get }
    var canGoBack: Bool { get }
    var canGoForward: Bool { get }
    func goBack() -> WKNavigation?
    func goForward() -> WKNavigation?
    func reload() -> WKNavigation?
    func reloadFromOrigin() -> WKNavigation?
    func stopLoading()
    func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject?, NSError?) -> Void)?)
    var allowsBackForwardNavigationGestures: Bool
    var customUserAgent: String?
    var allowsLinkPreview: Bool
    var scrollView: UIScrollView { get }
}

Declaration
From
func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject!, NSError!) -> Void)?)
To
func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject?, NSError?) -> Void)?)

Declaration
From
class WKWebViewConfiguration : NSObject, NSCopying {
    var processPool: WKProcessPool
    var preferences: WKPreferences
    var userContentController: WKUserContentController
    var suppressesIncrementalRendering: Bool
    var allowsInlineMediaPlayback: Bool
    var mediaPlaybackRequiresUserAction: Bool
    var mediaPlaybackAllowsAirPlay: Bool
    var selectionGranularity: WKSelectionGranularity
}
To
class WKWebViewConfiguration : NSObject, NSCopying {
    var processPool: WKProcessPool
    var preferences: WKPreferences
    var userContentController: WKUserContentController
    var websiteDataStore: WKWebsiteDataStore
    var suppressesIncrementalRendering: Bool
    var applicationNameForUserAgent: String?
    var allowsAirPlayForMediaPlayback: Bool
    var allowsInlineMediaPlayback: Bool
    var requiresUserActionForMediaPlayback: Bool
    var selectionGranularity: WKSelectionGranularity
    var allowsPictureInPictureMediaPlayback: Bool
}
extension WKWebViewConfiguration {
    var mediaPlaybackRequiresUserAction: Bool
    var mediaPlaybackAllowsAirPlay: Bool
}

Deprecation
From--
ToiOS 9.0

Deprecation
From--
ToiOS 9.0