View fizzbuzz.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hey, we've all got a coding interview to crack, right? | |
#import <Foundation/Foundation.h> | |
@interface FZBZSparseArray : NSArray | |
- initWithCount:(NSUInteger)count placeholder:placeholder overrides:overrides; | |
@end | |
@interface FZBZWrappedArray : NSArray | |
- initWrappingArray:underlyingArray; |
View ContractEnforcer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
NS_ASSUME_NONNULL_BEGIN | |
@interface ContractEnforcer<T> : NSProxy | |
- (T)initWithTarget:(T)target; | |
+ (T)enforcerWithTarget:(T)target; |
View gist:f11278d97799aebaa369
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) | |
Target: x86_64-apple-darwin14.3.0 | |
Thread model: posix | |
"/Applications/Xcode_6_3_2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -syslibroot /Applications/Xcode_6_3_2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -o /Users/leeg/Library/Developer/Xcode/DerivedData/ClassBrowser-gmbtduezhzgclfddsisfkakriqlj/Build/Products/Debug/ClassBrowser.app/Contents/MacOS/ClassBrowser -L/Users/leeg/Library/Developer/Xcode/DerivedData/ClassBrowser-gmbtduezhzgclfddsisfkakriqlj/Build/Products/Debug -L/usr/local/lib -filelist /Users/leeg/Library/Developer/Xcode/DerivedData/ClassBrowser-gmbtduezhzgclfddsisfkakriqlj/Build/Intermediates/ClassBrowser.build/Debug/ClassBrowser.build/Objects-normal/x86_64/ClassBrowser.LinkFileList -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMIRReader -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMBP |
View mutable-objects-in-immutable-methods-on-a-mutable-runtime.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
@interface Mutable : NSObject | |
@property (nonatomic, retain) id x; | |
@end | |
@implementation Mutable |
View ObjS.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
typealias Selector = String | |
enum IMP { | |
case accessor((Selector->IMP, Selector)->((Selector)->IMP)?) | |
case asInteger((Selector->IMP, Selector)->Int?) | |
case methodMissing((Selector->IMP, Selector)->((Selector)->IMP)?) | |
case mutator((Selector->IMP, Selector, Selector->IMP)->Void) | |
case description((Selector->IMP, Selector)->String?) |
View onceperthread.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#include <pthread.h> | |
void logExactlyOnce(void) | |
{ | |
static __thread dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
NSLog(@"Only done once?"); | |
}); | |
} |
View blockmaybefixed.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface A : NSObject | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler; | |
@end | |
@implementation A | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler | |
{ | |
NSLog(@"object: %@", o); |
View blockretain.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface A : NSObject | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler; | |
@end | |
@implementation A | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler | |
{ | |
NSLog(@"object: %@", o); |
View UIColor_literal.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
UIColor * operator"" _c(unsigned long long color) | |
{ | |
unsigned long long redComponent = (color & 0xff0000 >> 16); | |
unsigned long long greenComponent = (color & 0x00ff00) >> 8; | |
unsigned long long blueComponent = color & 0xff; | |
float red = redComponent / 255.0; | |
float green = greenComponent / 255.0; | |
float blue = blueComponent / 255.0; |
View gist:7004314
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <dispatch/dispatch.h> | |
#import <objc/runtime.h> | |
void printMethodList(Class cls, const char *prefix) | |
{ | |
const char *className = class_getName(cls); | |
unsigned int countOfMethods; | |
Method *methodList = class_copyMethodList(cls, &countOfMethods); | |
for(unsigned int i = 0; i < countOfMethods; i++) |
NewerOlder