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
PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in | |
if status == .authorized { | |
var infos: [(CLLocation, Date)] = [] | |
do { | |
let options = PHFetchOptions() | |
options.includeHiddenAssets = true | |
PHAsset.fetchAssets(with: options).enumerateObjects { asset, _, _ in | |
if let location = asset.location, | |
let date = asset.creationDate | |
{ |
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
private final class AppInfo { | |
private struct Keys { | |
static let lastKnownAppVersion = "app_data.last_known_app_version" | |
static let appWasInBackground = "app_data.app_was_in_background" | |
static let appWasTerminated = "app_data.app_was_terminated" | |
} | |
struct State { | |
let appVersionIsChanged: Bool | |
let appWasInBackground: Bool |
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
abacus | |
accordion | |
acorn | |
acrobat | |
adult | |
adult_cat | |
agriculture | |
aircraft | |
airplane | |
airport |
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
func testMultiThreadReadWriteRelations() { | |
TestDB.temporaryContainer(store: DataModels.bookLibrary) { pc in | |
let group = DispatchGroup() | |
let range = 1 ... 100 | |
try pc.perform { ctx in | |
try ctx.insert(BookLibrary.Author(id: .init(), name: "Leo", age: 100)) | |
} |
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
extension MTLCaptureManager { | |
@discardableResult | |
func capture<T>(with commandQueue: MTLCommandQueue, _ action: () throws -> T) throws -> T { | |
let scope = self.makeCaptureScope(commandQueue: commandQueue) | |
let descriptor = MTLCaptureDescriptor() | |
descriptor.captureObject = scope | |
try self.startCapture(with: descriptor) | |
scope.begin(); defer { scope.end() } |
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 UIKit | |
import MediaPlayer | |
extension Notification.Name { | |
static let systemVolumeDidChange = Notification.Name( | |
rawValue: "AVSystemController_SystemVolumeDidChangeNotification" | |
) | |
} | |
class ViewController: UIViewController { |
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
private final class OSUnfairLock { | |
private let pointer: os_unfair_lock_t | |
init() { | |
self.pointer = .allocate(capacity: 1) | |
self.pointer.initialize(to: os_unfair_lock()) | |
} | |
deinit { | |
self.pointer.deinitialize(count: 1) |
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
// umbrella.h | |
#pragma once | |
@import Foundation; | |
#include "../yoga/Yoga.h" | |
#include "../yoga/YGMacros.h" | |
#include "../yoga/YGValue.h" | |
#include "../yoga/YGEnums.h" |
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 CoreHaptics | |
protocol HapticFeedback { | |
func generateFeedback() | |
} | |
final class Haptic: HapticFeedback { | |
private let generator: HapticFeedback | |
init() { |
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
final class SharedOperation<T, E: Swift.Error> { | |
typealias Completion = (Result<T, E>) -> Void | |
private let queue = DispatchQueue(label: "SharedOperation.queue") | |
private let execute: (@escaping Completion) -> Void | |
private var completions: [Completion] = [] | |
init(_ execute: @escaping (@escaping Completion) -> Void) { | |
self.execute = execute |