Skip to content

Instantly share code, notes, and snippets.

Working a day job.

Robert Böhnke robb

Working a day job.
Block or report user

Report or block robb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
robb / Example.m
Last active Sep 25, 2018
A macro to convert nullable references to nonnull references while triggering an assert if the expression is actually true. Think of this as unsafe unwrap for Objective-C.
View Example.m
void Log(NSString *foo) {
NSLog(@"%@", foo);
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSDictionary *stuff = @{
@"a": @"Test"
View SBJson.podspec.json
"name": "SBJson",
"version": "4.0.2",
"license": {
"type": "BSD",
"text": " Copyright (C) 2007-2015 Stig Brautaset. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n * Neither the name of the author nor the names of its contributors may be used\n to endorse or promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L
View Contents.swift
import Foundation
typealias JSONDictionary = [String: AnyObject]
/// Attempts to load a data from a given URL.
func loadData(URL: NSURL) -> Either<NSError, NSData> {
if let data = NSData(contentsOfURL: URL) {
return Either.Right(Box(data))
} else {
// In a real world scenario, we'd have a more useful error :-)
View Lens.swift
import Prelude
public struct Lens<A, B> {
private let get: A -> B
private let set: (A, B) -> A
public init(get: A -> B, set: (A, B) -> A) {
self.get = get
self.set = set
View underscore.m
// No blocks-as-properties, just classic arguments
NSArray *tweets = [[[[[Underscore
reject:^(NSDictionary *tweet) {
return [tweet[@"iso_language_code"] isEqualToString:@"en"];
map:^(NSDictionary *tweet) {
NSString *name = tweet[@"from_user_name"];
robb / gist:8777652
Created Feb 3, 2014
boolean operators for matchers
View gist:8777652
@interface FooTests : XCTestCase
@implementation FooTests
- (void)testAnd {
View gist:7170438
Running 136 tests:
# ----- XCode (OCUnit) Test Output --------------------
Test Case '-[AsyncSpecTest testAsyncSpec]' started.
Test Case '-[AsyncSpecTest testAsyncSpec]' passed (0.036 seconds).
Test Case '-[AsyncSpecTest2 testBeforeAllAndAfterAllHooks]' started.
Test Case '-[AsyncSpecTest2 testBeforeAllAndAfterAllHooks]' passed (0.000 seconds).


Mantle makes it easy to write a simple model layer for your Cocoa or Cocoa Touch application.

Getting Started

To start building the framework, clone this repository and then run script/bootstrap. This will automatically pull down any dependencies.

View MTLManagedObjectAdapter.m
// MTLManagedObjectAdapter.m
- (NSPredicate *)uniquingPredicateForModel:(MTLModel<MTLManagedObjectSerializing> *)model {
NSSet *propertyKeys = nil;
if ([self.modelClass respondsToSelector:@selector(propertyKeysForManagedObjectUniquing)]) {
propertyKeys = [self.modelClass propertyKeysForManagedObjectUniquing];
NSPredicate *predicate = nil;
for (NSString *propertyKey in propertyKeys) {
You can’t perform that action at this time.