Skip to content

Instantly share code, notes, and snippets.

@avargaskun
avargaskun / SVG.swift
Last active May 7, 2024 08:42 — forked from ollieatkinson/SVG.swift
Utilise the private CoreSVG framework in Swift
import Darwin
import Foundation
import UIKit
@objc
class CGSVGDocument: NSObject { }
var CGSVGDocumentRetain: (@convention(c) (CGSVGDocument?) -> Unmanaged<CGSVGDocument>?) = load("CGSVGDocumentRetain")
var CGSVGDocumentRelease: (@convention(c) (CGSVGDocument?) -> Void) = load("CGSVGDocumentRelease")
var CGSVGDocumentCreateFromData: (@convention(c) (CFData?, CFDictionary?) -> Unmanaged<CGSVGDocument>?) = load("CGSVGDocumentCreateFromData")
final class PublicKeyPinner {
/// Stored public key hashes
private let hashes: [String]
public init(hashes: [String]) {
self.hashes = hashes
}
/// ASN1 header for our public key to re-create the subject public key info
private let rsa2048Asn1Header: [UInt8] = [
@JadenGeller
JadenGeller / Init Bool With Int.swift
Created March 23, 2015 07:48
Cast Int to Bool in Swift
extension Bool {
init<T : IntegerType>(_ integer: T){
self.init(integer != 0)
}
}
// Now you can do this
let x = Bool(5) // true
let y = Bool(-1) // true
let z = Bool(0) // false
@shto
shto / NSManagedObject+Cloner.h
Last active April 20, 2018 04:53
NSManagedObject cloner files
#import <CoreData/CoreData.h>
@interface NSManagedObject (Cloner)
- (NSManagedObject *)clone;
- (NSManagedObject *)cloneInContext:(NSManagedObjectContext *)differentContext;
@end