Skip to content

Instantly share code, notes, and snippets.

View guidedways's full-sized avatar
😑
Focusing

Beehive Innovations guidedways

😑
Focusing
View GitHub Profile
@samwarnick
samwarnick / migrate.swift
Last active January 25, 2023 16:11
Migrate to app group
// In my core data stack
let container = NSPersistentCloudKitContainer(name: "DataModel")
let storeUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupIdentifier)!.appendingPathComponent("DataModel.sqlite")
// Enable history tracking and remote notifications
guard let description = container.persistentStoreDescriptions.first else {
fatalError("###\(#function): Failed to retrieve a persistent store description.")
}
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
@b3ll
b3ll / BlurryVibrantView.swift
Created November 10, 2019 07:15
iOS SwiftUI Blurry Vibrant Container View
//
// BlurryVibrantView.swift
//
//
// Created by Adam Bell on 11/9/19.
// Copyright © 2019 Adam Bell. All rights reserved.
//
import SwiftUI
import UIKit
@pipacs
pipacs / PromiseOperation.swift
Created December 12, 2018 21:27
An (NS)Operation wrapping a Promise
import Foundation
import PromiseKit
class PromiseOperation<T>: Operation {
var result: T? = nil
var error: Error?
var promise: Promise<T>
override var isExecuting: Bool {
get {return _isExecuting}
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 11, 2024 08:56
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

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.