Author: Chris Lattner
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
extension Signal where Error == NoError { | |
public func sample(each timeInterval: DispatchTimeInterval, | |
on scheduler: DateScheduler = QueueScheduler()) -> Signal<[Value], NoError> { | |
return Signal<[Value], NoError> { observer in | |
let valueHolder : MutableProperty<[Value]> = MutableProperty<Value>([]) | |
let disposable = CompositeDisposable() | |
var sampler: Signal<(), NoError>? = nil | |
disposable += timer(interval: until, on: QueueScheduler()).startWithSignal { signal, _ in | |
signal = innerSignal.map { _ in () } | |
} |
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 | |
import MASShortcut | |
func pow() { | |
let rect = NSScreen.mainScreen()?.frame | |
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false) | |
window.backgroundColor = NSColor.clearColor() | |
window.opaque = false | |
window.alphaValue = 1 | |
window.makeKeyAndOrderFront(NSApplication.sharedApplication()) |
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 UIKit | |
// If you enjoyed this talk (video link will be up soon), then you might also enjoy our book Advanced Swift: http://www.objc.io/books/advanced-swift | |
struct Person { | |
let name: String | |
let city: String | |
} | |
let people = [ |
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 Thunder { } | |
class Fire { } | |
protocol Pokemon { | |
typealias PokemonType | |
func attack(move:PokemonType) | |
} | |
struct Pikachu: Pokemon { | |
typealias PokemonType = Thunder |
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 tips is extremely useful when you test your CoreData app in Unit Test. | |
*/ | |
// iOS app is an executable bundle, means the `main` method is | |
// included inside app bundle, so `mainBundle` returns the app bundle | |
// | |
// See doc at https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003624 | |
NSBundle *appBundle = [NSBundle mainBundle]; |