Skip to content

Instantly share code, notes, and snippets.

@grp
grp / if.swift
Created March 22, 2015 13:06
Swift custom statements
// if
let a = 3
let b = 3
let c = 5
// else if
// let a = 3
// let b = 5
// let c = 5
@grp
grp / Hook.h
Created February 17, 2014 19:05
#import <objc/runtime.h>
#define HookMethod(cls_, sel_, ...) \
(^{ \
SEL _cmd = sel_; \
__block IMP __original = method_setImplementation(class_getInstanceMethod(cls_, _cmd), imp_implementationWithBlock(__VA_ARGS__)); \
})()
#define CallOriginal(...) \
@grp
grp / gist:3074235
Created July 9, 2012 04:40 — forked from drunknbass/gist:3074015
Swizzletastic
#include <objc/runtime.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SwizzleMyNizzleProtocol.h"
IMP SwizzleMethod(Class _class, SEL sel, IMP imp) {
if (_class == nil || sel == NULL || imp == NULL)
return NULL;