Skip to content

Instantly share code, notes, and snippets.

NSProgrammer /
Last active Jul 18, 2018
Integrating Twitter Network Layer (TNL) with Twitter Image Pipeline (TIP)
NSProgrammer /
Last active Apr 19, 2019
Comparing modern vs legacy graphics context rendering on iOS

legacy = UIGraphicsBeginImageContextWithOptions + UIGraphicsEndImageContext

modern = UIGraphicsImageRendererFormat + UIGraphicsImageRenderer

Take aways:

  • "modern" w/ prefersExtendedRange = NO
    • basically the same perf as "legacy"
    • probably a good idea to adopt since optimizations will likely be in "modern" first
  • "modern" w/ prefersExtendedRange = YES
NSProgrammer / MyDebugCoder.m
Created Feb 10, 2017
Subclass NSCoder to encode to NSObject hierarchy (for debugging)
View MyDebugCoder.m
@interface MyDebugCoder : NSCoder
+ (NSDictionary *)serializedJSONWithRootObject:(id<NSCoding, NSObject>)object;
@implementation MyDebugCoder
NSMutableDictionary *_jsonRoot;
NSMutableArray *_values;
NSProgrammer / CFRuntimeBase_struct_size.m
Created Feb 10, 2017
Determine the size of the CFRuntimeBase at runtime
View CFRuntimeBase_struct_size.m
static size_t _CFRuntimeBaseGetSize()
static size_t sSize = 0;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// CFUUID has a very nice feature in that it's structure
// is always the CFRuntimeBase struct (which we don't have access to)
// followed by a UUID in bytes.
// By simply traversing the CFUUID structs byte layout until we find
You can’t perform that action at this time.