This file contains 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
// | |
// NSObject+BlockObservation.h | |
// Version 1.0 | |
// | |
// Andy Matuschak | |
// [email protected] | |
// Public domain because I love you. Let me know how you use it. | |
// | |
#import <Cocoa/Cocoa.h> |
This file contains 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
#include <stdarg.h> | |
#import <Foundation/Foundation.h> | |
@interface Cls : NSObject {} | |
-(int) takes_block: (int)limit withBlock:(int (^)(int first, ...))block; | |
@end | |
@implementation Cls | |
-(int) takes_block: (int)limit withBlock:(int (^)(int first, ...))block { |
This file contains 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
NSURLConnection | NSURLSession | |
------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------- | |
NSURLConnectionDelegate connectionShouldUseCredentialStorage: | | |
------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------- | |
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler: | |
| N |
This file contains 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
// Adapted from Cocoa Drawing Guide's "Create a CGPathRef fram an NSBezierPath Object" | |
func CGPathFromNSBezierPath(nsPath: NSBezierPath) -> CGPath! { | |
if nsPath.elementCount == 0 { | |
return nil | |
} | |
let path = CGPathCreateMutable() | |
var didClosePath = false | |
This file contains 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
struct HashSet<T : Hashable> { | |
typealias Element = T | |
var _map: Dictionary<T, ()> = [:] | |
var count: Int { | |
return _map.count | |
} | |
var isEmpty: Bool { |
This file contains 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
// Creating a generic recursive data structure with autoclosure. (READ ALL NOTES; THIS MAY NOT DO WHAT YOU WANT.) | |
// Closures are reference types, so the size is known (? I think ?) | |
// Note that this is just because of unimplemented features in the compiler in Beta5 | |
// There's no reason to think this is a long-term requirement. | |
// IMPORTANT: the closure will run every time you access this value, so if that has | |
// side effects, this won't work. It's only possible on pure value types. | |
// But the fact that this works as expected is actually kind of incredible. | |
// Think about what is required for it to work out the type for NestedList.Elem("first"). |