(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| /// Observes a run loop to detect any stalling or blocking that occurs. | |
| /// | |
| /// This class is thread-safe. | |
| @interface GHRunLoopWatchdog : NSObject | |
| /// Initializes the receiver to watch the specified run loop, using a default | |
| /// stalling threshold. | |
| - (id)initWithRunLoop:(CFRunLoopRef)runLoop; | |
| /// Initializes the receiver to detect when the specified run loop blocks for |
| enum ShiftKeyType { | |
| case None | |
| case Once | |
| case Always | |
| } | |
| enum PunctuationSwitcherType { | |
| case More | |
| case Numeric | |
| } |
| // Playground - noun: a place where people can play | |
| import UIKit | |
| // MARK: Utilities | |
| func take<T>(slice: Slice<T>, num: Int) -> Slice<T> { | |
| let n = (num < slice.count) ? num : slice.endIndex | |
| return slice[0..<n] | |
| } |
| /*/../usr/bin/true | |
| source="$0" | |
| compiled="$0"c | |
| if [[ "$source" -nt "$compiled" ]]; then | |
| DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -g "$source" -o "$compiled" || exit | |
| fi | |
| "$compiled" |
| // | |
| // LTLog.h | |
| // | |
| // Created by Lex on 6/29/14. | |
| // Copyright (c) 2014 LexTang.com. All rights reserved. | |
| // https://gist.github.com/lexrus/8c6414e7c0177e9e66ea | |
| // | |
| #import <Foundation/Foundation.h> |
| import UIKit | |
| import Security | |
| let serviceIdentifier = "com.company" | |
| let accessGroup = "com.company.app" | |
| let kSecClassValue = kSecClass as NSString | |
| let kSecAttrAccountValue = kSecAttrAccount as NSString | |
| let kSecValueDataValue = kSecValueData as NSString | |
| let kSecClassGenericPasswordValue = kSecClassGenericPassword as NSString |
| // This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html | |
| // | |
| // As of Beta5, the >>= operator is already defined, so I changed it to >>>= | |
| import Foundation | |
| let parsedJSON : [String:AnyObject] = [ | |
| "stat": "ok", | |
| "blogs": [ |
| // Created by Robert Widmann on 7/16/14. | |
| // Copyright (c) 2014 CodaFi. All rights reserved. | |
| // | |
| #define stringify(x) #x | |
| #define namespaced_interface(space, klass) class NSObject; \ | |
| __attribute__((objc_runtime_name(stringify(space.klass)))) \ | |
| @interface klass | |
| #define namespaced_protocol(space, proto) class NSObject; \ |
| // See: https://devforums.apple.com/message/1000934#1000934 | |
| import Foundation | |
| // Logic | |
| operator prefix ¬ {} | |
| @prefix func ¬ (value: Bool) -> Bool { | |
| return !value | |
| } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.