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
context | |
context | |
-AAAA | |
-AAAA | |
-AAAA | |
+BBBB | |
+BBBB | |
+BBBB | |
+BBBB | |
{ |
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
// What I would expect: | |
(lldb) p newPaths | |
([AnyObject]) $R1 = 2 values { | |
[0] = "This is a string", | |
[1] = "This is another string" | |
} | |
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
// The Swift Programming Language book from Apple states the following: | |
// | |
// Swift automatically provides shorthand argument names to inline closures, | |
// which can be used to refer to the values of the closure’s arguments by the | |
// names $0, $1, $2, and so on. | |
// In Xcode 6.1 and 6.2b1, it appears that this is only true IF the last argument | |
// is referenced using shorthand syntax somewhere in the closure body. See below | |
// for details. |
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
protocol FooProtocol { | |
func blah() | |
} | |
struct Foo : FooProtocol { | |
func blah() {} | |
} |
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
import Cocoa | |
func curry<A, B, C> ( f: (A, B) -> C ) -> (A -> B -> C) { | |
return { x in | |
return { y in | |
return f(x, y) | |
} | |
} | |
} |
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
class Top { | |
let x: Int | |
init() { x = 3; println("Top.init") } | |
} | |
class Bottom: Top { | |
var z: String | |
// This doesn't call `super.init`, but Top.init still runs. Why? | |
init(dummy: Bool) { z = "hi" } |
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
#import <Foundation/Foundation.h> | |
// This is pretty simple, right? | |
typedef void(^SampleBlock)(NSString *str); |
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
NSMutableArray *a = [NSMutableArray array]; | |
[a addObject:a]; | |
NSLog(@"a: %@", a); |
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
#! /usr/local/bin/macruby | |
framework "ScriptingBridge" | |
iTunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") | |
iTunes.currentTrack.name |
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
// This is a useful bit of code for waiting for the results of an | |
// asynchronous operation. It's especially useful in unit tests. | |
// It keeps the run loop going, so it's not blocking delegate callbacks. | |
BOOL waitForBlock(NSTimeInterval timeout, | |
BOOL (^condition)(void)) { | |
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout]; | |
BOOL val = condition(); | |
while ( val == NO && [timeoutDate timeIntervalSinceNow] > 0 ) { | |
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]; |