Skip to content

Instantly share code, notes, and snippets.

@kylehowells
kylehowells / UIKit — Full ObjC API Diff: iOS 26.2 → iOS 27 (beta).md
Created June 8, 2026 22:03
UIKit — Full ObjC API Diff: iOS 26.2 → iOS 27 (beta) - Generated by Claude Code from Xcode-beta.app

UIKit — Full ObjC API Diff: iOS 26.2 → iOS 27 (beta)

Old: Xcode 26.2 (iPhoneOS26.2 SDK) · New: Xcode 27 beta (iPhoneOS 27.0 SDK)

Scope: public ObjC headers of UIKit.framework (iPhoneOS device SDK).

Legend (inside diff blocks): + added · - removed · ~ newly deprecated/obsoleted · ±/ signature changed (old → new).


@glukianets
glukianets / 8Queens.swift
Created August 15, 2024 15:38
Naive 8Queens puzzle solution with bitmasks
func queen(atFile file: Int, rank: Int) -> UInt64 {
0b00000001_00000001_00000001_00000001_00000001_00000001_00000001_00000001 << (file) |
0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_11111111 << (rank * 8) |
0b10000000_01000000_00100000_00010000_00001000_00000100_00000010_00000001 >> ((file - rank) * 8) |
0b00000001_00000010_00000100_00001000_00010000_00100000_01000000_10000000 >> ((7 - file - rank) * 8)
}
func occupiedIndices(in board: UInt64) -> some Sequence<(file: Int, rank: Int)> {
sequence(state: (board, 0)) { state in
let offset = state.0.trailingZeroBitCount
@timonus
timonus / programmatic-dynamic-images.m
Last active January 1, 2024 12:08
Programmatically create iOS 13 dynamic images
- (UIImage *)dynamicImage
{
UITraitCollection *const baseTraitCollection = /* an existing trait collection */;
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]];
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]];
__block UIImage *lightImage;
[lightTraitCollection performAsCurrentTraitCollection:^{
lightImage = /* draw image */;
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 11, 2026 20:02
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 27, 2026 19:27 — 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.

@eleev
eleev / UIImage+SolidColor.swift
Created March 24, 2017 11:18
Extension for creating UIImage from a UIColor. Swift 3
extension UIImage {
convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
let rect = CGRect(origin: .zero, size: size)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
color.setFill()
UIRectFill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
guard let cgImage = image?.cgImage else { return nil }
@jay18001
jay18001 / Matrix4.swift
Created February 24, 2017 02:57
Swift version of helper class from Ray Wenderlich: Metal Tutorial with Swift 3 Part 2
import UIKit
import GLKit
extension Float {
var radians: Float {
return GLKMathDegreesToRadians(self)
}
}
class Matrix4 {
@matthiasnagel
matthiasnagel / UIImageFixedOrientationExtension.swift
Created January 19, 2017 09:36 — forked from schickling/UIImageFixedOrientationExtension.swift
Extension to fix orientation of an UIImage (Sets orientation to portrait)
import UIKit
extension UIImage {
public func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.up {
return self
}
@eleev
eleev / URLForPHAsset.swift
Last active April 2, 2025 13:33
Getting URL for PHAsset (Swift 3.0)
func getURL(ofPhotoWith mPhasset: PHAsset, completionHandler : @escaping ((_ responseURL : URL?) -> Void)) {
if mPhasset.mediaType == .image {
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
mPhasset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
completionHandler(contentEditingInput!.fullSizeImageURL)
})
@velyan
velyan / StateMachine.swift
Last active July 17, 2025 00:46
Swift State Pattern
import Foundation
fileprivate protocol Statelike {
var stateMachine: StateMachine { get }
func logIn()
func logOut()
}
extension Statelike {
func logIn() {}