For a list of known timezone supported in NSTimeZone, log:
[NSTimeZone knownTimeZoneNames]The full list:
(lldb) po [NSTimeZone knownTimeZoneNames]
<__NSCFArray 0x7fba91903000>(
| function lols { | |
| random_num=$RANDOM | |
| let "random_num %= 20" | |
| if [ $random_num -eq 0 ]; then | |
| alias hg="say hg && /usr/local/bin/hg" | |
| else | |
| alias hg="/usr/local/bin/hg" | |
| fi | |
| } |
For a list of known timezone supported in NSTimeZone, log:
[NSTimeZone knownTimeZoneNames]The full list:
(lldb) po [NSTimeZone knownTimeZoneNames]
<__NSCFArray 0x7fba91903000>(
When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.
So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.
Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?
I'm going to cover three things in this post:
| import Cocoa | |
| struct Person { | |
| var name: String = "John" | |
| var age: Int = 50 | |
| var dutch: Bool = false | |
| var address: Address? = Address(street: "Market St.") | |
| } | |
| struct Address { |
PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug
Speaker: David Abrahams. (Tech lead for Swift standard library)
"Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.
OOP has been around since the 1970's. It's not actually new.
Classes are Awesome
| extension UIColor { | |
| convenience init(_ hexValue: Int) { | |
| let r = (hexValue & 0xFF0000) >> 16 | |
| let g = (hexValue & 0x00FF00) >> 8 | |
| let b = hexValue & 0x0000FF | |
| self.init(red: CGFloat(r)/255, green: CGFloat(g)/255, blue: CGFloat(b)/255, alpha: 1) | |
| } | |
| struct Zip3Generator | |
| < | |
| A: GeneratorType, | |
| B: GeneratorType, | |
| C: GeneratorType | |
| >: GeneratorType { | |
| private var first: A | |
| private var second: B |
| /// 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 |
| #!/usr/bin/env ruby | |
| device_types_output = `xcrun simctl list devicetypes` | |
| device_types = device_types_output.scan /(.*) \((.*)\)/ | |
| runtimes_output = `xcrun simctl list runtimes` | |
| runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
| devices_output = `xcrun simctl list devices` | |
| devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
| // | |
| // Warnings.xcconfig | |
| // | |
| // The list of warnings we (don’t) use, and the reasons why. | |
| // | |
| // :MARK: Warnings in use: | |
| // :MARK: -everything | |
| // We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us. | |
| // | |
| // :MARK: - Warnings not to be promoted: |