This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Dispatch | |
@_silgen_name("dispatch_sync") private func os_dispatch_sync(queue: dispatch_queue_t, @noescape _ block: dispatch_block_t) | |
@_silgen_name("dispatch_barrier_sync") private func os_dispatch_barrier_sync(queue: dispatch_queue_t, @noescape _ block: dispatch_block_t) | |
private func dispatch_sync_rethrow_wrapper<Return>(queue: dispatch_queue_t, @noescape dispatcher: (dispatch_queue_t, dispatch_block_t) -> Void, @noescape body: () throws -> Return, @noescape onError: ErrorType throws -> Void) rethrows -> Return { | |
var ret: Return! | |
var innerError: ErrorType? | |
os_dispatch_sync(queue) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Derived from http://blog.krzyzanowskim.com/2015/10/24/chunksequence-have-cake-and-eat-it/ | |
struct ChunkSequence<Element>: SequenceType { | |
typealias Collection = AnyForwardCollection<Element> | |
let collection: Collection | |
let chunkSize: Collection.Index.Distance | |
private init<C: CollectionType where C.Index: ForwardIndexType, C.Generator.Element == Element>(_ base: C, chunkSize: C.Index.Distance) { | |
self.collection = AnyForwardCollection(base) | |
self.chunkSize = chunkSize.toIntMax() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DynamicTypeLabel.swift | |
// | |
// Created by Indragie on 10/16/14. | |
// Copyright (c) 2014 Indragie Karunaratne. All rights reserved. | |
// | |
import UIKit | |
class DynamicTypeLabel : UILabel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (c) 2012-2013 Cédric Luthi / @0xced. All rights reserved. | |
// | |
#if TARGET_IPHONE_SIMULATOR | |
@interface NSObject () | |
- (void)setItem:(int)item enabled:(BOOL)enabled; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clang -framework Foundation -fobjc-arc -O3 test.m | |
#import <Foundation/Foundation.h> | |
@interface NSNumber (RangeCreation) | |
- (NSValue *): (NSInteger)length; | |
@end |