Skip to content

Instantly share code, notes, and snippets.

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

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
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;
@end
@implementation MyDebugCoder
{
NSMutableDictionary *_jsonRoot;
NSMutableArray *_values;
}
@NSProgrammer
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.