Skip to content

Instantly share code, notes, and snippets.

View AccountStore.swift
class AccountStore {
// Doesn't work yet
class var sharedStore = ACAccountStore()
// This works although I'm unsure of the optional
class func sharedStore() -> ACAccountStore {
var store: ACAccountStore? = nil
var token: dispatch_once_t = 0
dispatch_once(&token, {
View error.swift
// Playground - noun: a place where people can play
import Foundation
enum Result<ValueType, ErrorType> : LogicValue {
case Value(ValueType)
case Error(ErrorType)
var successful : Bool {
get {
View Hacking UIView Animation

Hacking UIView animation blocks for fun and profit

In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.

As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.

In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.

Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.

View MusicPlayer.m
MPMusicPlayerController *controller = [MPMusicPlayerController iPodMusicPlayer];
MPMediaPropertyPredicate *artistPredicate = [MPMediaPropertyPredicate predicateWithValue:@"The Killers"
MPMediaQuery *query = [[MPMediaQuery alloc] initWithFilterPredicates:[NSSet setWithArray:@[artistPredicate]]];
for (MPMediaItem *song in query.items) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
romaonthego / gist:823233
Created Feb 11, 2011
Remove .DS_Store (Mac OS X)
View gist:823233
sudo find /WebServers -name ".DS_Store" -depth -exec rm {} \;
romaonthego / gist:859697
Created Mar 8, 2011
Local IP on Debian/Ubuntu
View gist:859697
ifconfig|grep 'inet addr'|awk '{print $2}'|sed 's/addr://g'
View Closure.swift
self.errorView = {
let view = UIView()
view.backgroundColor = UIColor.redColor()
self.errorLabel = {
let label = UILabel()
label.textAlignment = .Center
label.backgroundColor = UIColor.clearColor()
return label
romaonthego / kill.rb
Created Dec 9, 2015 — forked from timonus/kill.rb
Deletes all yer iOS simulators
View kill.rb
#!/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 /(.*) \(.*\) \(([^)]+)\)$/
devices_output = `xcrun simctl list devices`
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/
View gist:6942007
typedef enum _UIBackgroundStyle {
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)



To create a method to persist and re-instantiate Mantle MTLModel objects to NSUbiquitousKeyValueStore (iCloud key-value store).


NSUbiquitousKeyValueStore can only store values of class NSNumber, NSString, NSDate, NSData, NSArray, and NSDictionary ("plist types"). The MTLNSUbiquitousKeyValueStore category on MTLModel has been designed to create an NSDictionary representation of a model object in a deeply recursive way, making it suitable for storage in an NSUbiquitousKeyValueStore.