Skip to content

Instantly share code, notes, and snippets.

@deze333
deze333 / SingleThreadExecutor.swift
Last active September 30, 2018 09:51
Multi-thread to single-thread synchronized executor pattern in Swift (playground)
// Multi to single thread execution
// https://stackoverflow.com/questions/47724198/sync-calls-from-swift-to-c-thread-unsafe-library/47764223#47764223
// Credits go to https://stackoverflow.com/users/819340/paulo-mattos
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(10 * 60)) {
print("Done")
@deze333
deze333 / BottleneckExecutor.swift
Last active December 12, 2017 06:03
Multi-thread to single-thread synchronized executor pattern in Swift using run loop and a custom operation object (playground)
// Multi to single thread execution
// Implemented via a run loop and a custom operation object reference passing
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3000)) {
print("Done")
PlaygroundPage.current.finishExecution()
@deze333
deze333 / WorkUnitExecutor.swift
Created December 12, 2017 11:51
Multi-thread to single-thread synchronized executor pattern in Swift (playground)
// Multi to single thread execution
// Credits go to https://www.reddit.com/r/swift/comments/7ijbt0/whats_a_good_way_to_make_sync_calls_from_swift_to/dr4iwxr/
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3000)) {
print("Done")
PlaygroundPage.current.finishExecution()
@deze333
deze333 / Podfile
Created January 30, 2018 05:19
Cocoapods post install script that ensures NSPrincipalClass is copied across to Info.plist of nominated pods. Without this NSPrincipalClass will be nil.
# Post install script that ensures that NSPrincipalClass
# is transferred from original info.plist to the pod generated info.plist.
post_install do |installer|
# Frameworks and their principal classes dictionary
frameworks_classes = {
'FrameworkA' => 'FrameworkAPrincipalClassName',
'FrameworkB' => 'FrameworkBPrincipalClassName'
}