This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// This isn't safe to use before Swift gets ABI stability, because generic classes | |
/// could change their names. Also, be sure to register bridges with the Obj-C runtime | |
/// if using to decode during iOS state restoration. | |
/// | |
class CodableBridge<Wrapped: Codable>: NSObject, NSSecureCoding { | |
let value: Wrapped | |
init(_ value: Wrapped) { self.value = value } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
let window = UIWindow(frame: UIScreen.main.bounds) | |
self.window = window |
- Proposal: SE-XXXX
- Authors: Chris Lattner, Joe Groff
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain | |
final class AppDelegate: UIResponder, UIApplicationDelegate { | |
let healthKitManager = HealthKitManager() | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
if onboardingComplete { | |
healthKitManager.requestAccessWithCompletion() { success, error in | |
if success { print("HealthKit access granted") } | |
else { print("Error requesting access to HealthKit: \(error)") } | |
} |