Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
static NSInteger NSJSONReadingFuckNSNulls = (1UL << 3);
@implementation NSJSONSerialization (FuckNulls)
+ (void)load {
Method originalMethod = class_getClassMethod(self, @selector(JSONObjectWithData:options:error:));
IMP swizzledImplementation = imp_implementationWithBlock([^id (id _self, NSData *_data, NSJSONReadingOptions _opt, NSError **_error){
NSInputStream *stream = [NSInputStream inputStreamWithData:_data];
[stream open];
@hectormatos2011
hectormatos2011 / UIGestureRecognizer+Closures.swift
Last active December 24, 2016 20:27
UIGestureRecognizer+Closures.swift
//
// UIGestureRecognizer+Closures.swift
// Closures
//
// Created by Hector on 7/23/14.
// Copyright (c) 2014 Hector Matos. All rights reserved.
//
import Foundation
@chriseidhof
chriseidhof / presentation.md
Created June 28, 2014 13:00
MobileOptimized Presentation

[fit] Functional Programming in

[fit] Swift

Chris Eidhof - objc.io - June 28, Minsk



@prabirshrestha
prabirshrestha / TextFieldChanges.m
Created August 2, 2012 13:53
Reactive Cocoa examples
@synthesize firstName = _firstName;
@synthesize txtFirstName = _txtFirstName;
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }];
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable];
- (void) firstNameChanged:(id)firstName {
NSLog(@"changed: %@", firstName);
}
@kristopherjohnson
kristopherjohnson / makeNewUUIDString-ARC.m
Created April 30, 2012 15:40
Create a new UUID string, ARC-compatible
+ (NSString *)makeNewUUIDString {
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return (__bridge_transfer NSString *)(string);
}
typealias verFunc = @convention(c) ()->UnsafePointer<CChar>
let libz = dlopen("libz.dylib", RTLD_LAZY)
let ret = dlsym(libz, "zlibVersion")
let zLibVersion = unsafeBitCast(ret, verFunc.self)
print("\(String.fromCString(zLibVersion())!)")