I enjoy making and playing with little DSL-ish extensions for Cocoa types in Swift. For instance, the code below allows me to write cool
storyboard.VC["foo_bar"]
storyboard.VC.initial
instead of:
require 'csv' | |
tweets = CSV.read('tweets.csv') | |
tweets.shift | |
stats = tweets | |
.reject { |t| t[5] =~ /^RT/ } | |
.group_by { |t| | |
date = Date.parse t[3] | |
"#{date.year}-#{date.month}" |
I enjoy making and playing with little DSL-ish extensions for Cocoa types in Swift. For instance, the code below allows me to write cool
storyboard.VC["foo_bar"]
storyboard.VC.initial
instead of:
// This will work: | |
var url: String | |
if condition { | |
url = "http://example.com" | |
} else { | |
url = "http://example.org" | |
} |
{ | |
"name": "MASShortcut", | |
"version": "1.2.3", | |
"summary": "Modern framework for managing global keyboard shortcuts compatible with Mac App Store.", | |
"description": " Some time ago Cocoa developers used a brilliant framework ShortcutRecorder for managing keyboard shortcuts in application preferences. However, it became incompatible with a new plugin architecture of Xcode 4. \n\n The project MASShortcut introduces modern API and user interface for recording, storing and using global keyboard shortcuts. All code is compatible with Xcode 4.3, Mac OS X 10.7 and the sandboxed environment.\n", | |
"homepage": "http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html", | |
"license": "BSD", | |
"authors": { | |
"Vadim Shpakovski": "vadim@shpakovski.com" | |
}, |
I hereby claim:
To claim this, I am signing this object:
class Foo { | |
struct Keys { | |
static let keychainGroup = "com.foo.keychain-group" | |
static let enabled = "foo.enabled" | |
} | |
// now you can just write `Keys.enabled`, `Keys.keychainGroup` inside of the Foo class. | |
} |
source 'https://github.com/CocoaPods/Specs.git' | |
target :iOS do | |
platform :ios, '7.1' | |
link_with 'YourAppTarget', 'WidgetExtension', 'ShareExtension' | |
# pods... | |
end | |
target :Mac do |
import Foundation | |
func foo() -> AnyObject? { | |
return NSDictionary() | |
} | |
func cast<A>(type: A.Type)(object: Any) -> A? { | |
return object as? A | |
} |
import Foundation | |
func foo() -> AnyObject? { | |
return NSDictionary() | |
} | |
func cast<A>(type: A.Type)(object: Any) -> A? { | |
return object as? A | |
} |
struct R { | |
struct Images { | |
static var doge: NSImage { | |
return NSImage(contentsOfFile: "...")! | |
} | |
} | |
} | |
R.Images.doge |