Skip to content

Instantly share code, notes, and snippets.

protocol OtherType {
typealias foo
}
protocol Foo: OtherType {
func extend<S : OtherType where S.foo == Self.foo>(sequence: S) -> S
}
import Foundation
class File: Sequence, Generator {
typealias GeneratorType = File
typealias Element = String
var handle: UnsafePointer<FILE>?
init(path: String) {
extension String {
subscript (r: Range<Int>) -> String {
let indexRange = Range(start: advance(self.startIndex, r.startIndex), end: advance(self.startIndex, r.endIndex))
return self[indexRange]
}
subscript (i: Int) -> Character {
return self[advance(self.startIndex, i)]
}
}
func async(queue: dispatch_queue_t, f: () -> Void) {
dispatch_async(queue, f)
}
func async(f: () -> Void) {
async(dispatch_get_main_queue(), f)
}
async {
println("Hello")
protocol Initializeable {
init()
}
extension Array: Initializeable {}
func create<T: Initializeable>(t: T.Type) -> T {
return t()
}
import UIKit
class TestView: UIView {
override func intrinsicContentSize() -> CGSize {
return CGSizeMake(100, 100)
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
//
// Constraints.swift
// ConstraintsTest
//
// Created by Joshua Weinberg on 6/6/14.
// Copyright (c) 2014 Joshua Weinberg. All rights reserved.
//
import UIKit
//
// ConstraintTypes.swift
// ConstraintsTest
//
// Created by Joshua Weinberg on 6/8/14.
// Copyright (c) 2014 Joshua Weinberg. All rights reserved.
//
import UIKit
//
// ConstraintTypes.swift
// ConstraintsTest
//
import UIKit
enum ConstraintDirection {
case Natural
case LTR
struct ReinterpretSequence<T, U> : Swift.Collection
{
typealias IndexType = Int
typealias GeneratorType = IndexingGenerator<ReinterpretSequence<T,U>>
let value: T
var startIndex: IndexType { return 0 }
var endIndex: IndexType { return sizeof(T) / sizeof(U) }