Skip to content

Instantly share code, notes, and snippets.

@karwa
karwa / codablebridge.swift
Created November 1, 2017 04:57
codable-nscoding bridge
import Foundation
/// This isn't safe to use before Swift gets ABI stability, because generic classes
/// could change their names. Also, be sure to register bridges with the Obj-C runtime
/// if using to decode during iOS state restoration.
///
class CodableBridge<Wrapped: Codable>: NSObject, NSSecureCoding {
let value: Wrapped
init(_ value: Wrapped) { self.value = value }
@calebd
calebd / Readme.markdown
Last active September 7, 2022 16:45
Run Loop Source

CFRunLoopSource is cool. It lets you build behavior similar to the mechanisms that drive setNeedsLayout and setNeedsDisplay in UIKit.

I found myself in need of something like this a couple of times. It's great to know that no matter how many times I say I need to update something, I will get a single callback at the end of the run loop that gives me a chance to perform my work.

Here is a little Swift wrapper that makes the API easier to deal with.

@TosinAF
TosinAF / TNPageViewController.m
Created May 24, 2015 18:30
Disabling UIPageViewController Swipe on certain areas of the screen
//
// TNPageViewController.m
// The News
//
// Created by Tosin Afolabi on 26/06/2014.
// Copyright (c) 2014 Tosin Afolabi. All rights reserved.
//
#import "TNPageViewController.h"