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; |
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; |
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
#!/usr/bin/perl -w | |
use strict; | |
use Foundation; | |
my $plist = NSDictionary->dictionaryWithContentsOfFile_("/Applications/TextEdit.app/Contents/Info.plist"); | |
print $plist->description()->UTF8String(); |
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?) |
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); |
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); |
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; |
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++) |
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> | |
typedef NS_ENUM(int, GJLRangeDirection) { | |
GJLRangeDirectionPositive, | |
GJLRangeDirectionNegative, | |
}; | |
@interface GJLRange : NSEnumerator | |
+ (instancetype)rangeWithStart: (NSNumber *)start end: (NSNumber *)end step: (NSNumber *)step; |
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 A : NSObject | |
- (void)createPrivateSubclass; | |
@end | |
int main(int argc, char *argv[]) | |
{ | |
@autoreleasepool |
NewerOlder