How to get JSContext from WKWebView

You cannot obtain the context, because layout and javascript is handled on another process. Instead, add scripts to your webview configuration, and set your view controller (or another object) as the script message handler. Now, send messages from JavaScript like so: window.webkit.messageHandlers.interOp.postMessage(message) Your script message handler will receive a callback: – (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message{ … Read more

MFMailComposeViewController in Swift

I compared MFMailComposeResult documentation on both Xcode 5 and Xcode 6. In Swift, MFMailComposeResult is a struct struct MFMailComposeResult { init(_ value: CUnsignedInt) // available in iPhone 3.0 var value: CUnsignedInt } with MFMailComposeResultCancelled as a constant of type MFMailComposeResult: var MFMailComposeResultCancelled: MFMailComposeResult { get } while it’s an enum in Objective-C: enum MFMailComposeResult { … Read more

Values not always persisted in App group between companion app & app extension

You must request open access in order to access shared NSUserDefaults. It’s stated directly in the App Extension Programming guide: By default, a keyboard has no network access and cannot share a container with its containing app. To enable these things, set the value of the RequestsOpenAccess Boolean key in the Info.plist file to YES. … Read more