Skip to content

Instantly share code, notes, and snippets.

View CrystDragon's full-sized avatar

Lincoln Wu CrystDragon

View GitHub Profile
@nevan
nevan / gist:3e1174f27e753db4731e
Last active January 9, 2022 19:04
WWDC 2015 Session Videos
https://developer.apple.com/videos/wwdc/2015/?id=101 101 Keynote
https://developer.apple.com/videos/wwdc/2015/?id=102 102 Platforms State of the Union
https://developer.apple.com/videos/wwdc/2015/?id=103 103 Apple Design Awards
https://developer.apple.com/videos/wwdc/2015/?id=104 104 What's New in Xcode
https://developer.apple.com/videos/wwdc/2015/?id=105 105 Introducing WatchKit for watchOS 2
https://developer.apple.com/videos/wwdc/2015/?id=106 106 What's New in Swift
https://developer.apple.com/videos/wwdc/2015/?id=107 107 What's New in Cocoa Touch
https://developer.apple.com/videos/wwdc/2015/?id=108 108 Building Watch Apps
https://developer.apple.com/videos/wwdc/2015/?id=112 112 Think Audacious
https://developer.apple.com/videos/wwdc/2015/?id=201 201 iOS Accessibility
@lattner
lattner / async_swift_proposal.md
Last active October 29, 2024 18:53 — 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.

@objc func _needsDoubleUpdateConstraintsPass() -> Bool {
return true
}
override var intrinsicContentSize: CGSize {
  return attributedText?.size(forWidth: (engineBounds ?? bounds).width) ?? .zero
}
var engineBounds: CGRect? {
let objcSelector = "_nsis_compatibleBoundsInEngine:")
@marcrasi
marcrasi / XXXX-constexpr.md
Last active April 19, 2024 21:10
Compile Time Constant Expressions for Swift
@ole
ole / UIAlertController+TextField.swift
Last active September 13, 2022 14:20
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@brennanMKE
brennanMKE / README.md
Last active June 4, 2024 13:36
LLDB customization with additional commands

LLDB Custom Commands

[LLDB] can be customized with ~/.lldbinit to run commands and to load more commands from shell and python scripts. One option is [Chisel] which provides several commands which can be used to debug an software running in Xcode.

It is critical that LLDB can process the commands in ~/.lldbinit successfully as a failure can cause the debugger to fail or run in an undefined way. The configuration listed in this Gist prints a message at the start and end so that when the debugger is run it is clear if any errors are shown in the Xcode console they are related to LLDB.

@IsaacXen
IsaacXen / README.md
Last active November 3, 2024 04:19
(Almost) Every WWDC videos download links for aria2c.
@DougGregor
DougGregor / SwiftConcurrencyDependencies.svg
Created December 2, 2020 00:39
Swift Concurrency Proposal Dependencies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DougGregor
DougGregor / preventing-data-races.md
Created December 20, 2020 06:49
Preventing Data Races in the Swift Concurrency Model

Preventing Data Races in the Swift Concurrency Model

One of the goals of the concurrency effort is to prevent data races. This document describes the approach taken to preventing data races overall, by categorizing the sources of data races and describing how they are addressed with other proposals in the Swift Concurrency effort.

Data races

A data race occurs when two threads access the same memory concurrently and at least one of the accesses can change the value. Within the safe subset of Swift (e.g., ignoring the use of UnsafeMutablePointer and related types), the memory in question is always a stored property. There are several different categories of stored properties that need to be considered for data races:

  • Global and static stored properties:
@DougGregor
DougGregor / parallel_map.swift
Created December 24, 2020 01:10
Swift async/await implementation of a parallel map
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async throws -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = self.count
if n == 0 {