I hereby claim:
- I am correia on github.
- I am jimcorreia (https://keybase.io/jimcorreia) on keybase.
- I have a public key ASAR4cttpEDJ44yvVnhwDGEEwo2B3VyxpkgQv-r4U-yAXQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// Strongly typed NSCopying/NSMutableCopying for Swift | |
import Cocoa | |
protocol Clonable: NSCopying { | |
func clone() -> Self | |
} | |
extension Clonable { | |
func clone() -> Self { |
// What does this program print? | |
import Foundation | |
for (var i = 0; i < 5; i++) { | |
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC))) | |
dispatch_after(delayTime, dispatch_get_main_queue()) { | |
print(i) | |
} | |
} |
// In Objective-C | |
typedef NSArray * (^ArrayReturningBlock)(void); | |
id BlockFromClosure(ArrayReturningBlock closure) | |
{ | |
return [closure copy]; | |
} | |
void CallBlockFromDictionary(NSDictionary *dictionary) |
// | |
// command-line-args.swift | |
// | |
// Created by Jim Correia on 6/4/14. | |
// Copyright (c) 2014-2015 Jim Correia. All rights reserved. | |
// | |
print("PROG_NAME = \(Process.arguments[0])") | |
print("ARGC = \(Process.argc)") | |
print("ARGV = \(Process.arguments)") |
// | |
// Swift-KVO | |
// | |
// Created by Jim Correia on 6/5/14. | |
// Copyright (c) 2014-2015 Jim Correia. All rights reserved. | |
// | |
// Update: 6/17/2014 | |
// | |
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context | |
// |