Skip to content

Instantly share code, notes, and snippets.

static OSStatus WrapperSecTrustEvaluate(SecTrustRef serverTrust, SecTrustResultType *result)
{
if (@available(iOS 13, *)) {
// SecTrustEvaluate is deprecated.
// Wrap new API to have same calling pattern as we had prior to deprecation.
// 1) call the new function to execut the evaluation
CFErrorRef error = NULL;
const bool evaluationSucceeded = SecTrustEvaluateWithError(serverTrust, &error);
@NSProgrammer
NSProgrammer / README.md
Last active August 5, 2020 22:18
Integrating Twitter Network Layer (TNL) with Twitter Image Pipeline (TIP)
@NSProgrammer
NSProgrammer / Overview.md
Last active March 7, 2023 08:06
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
NSProgrammer / MyDebugCoder.m
Created February 10, 2017 20:31
Subclass NSCoder to encode to NSObject hierarchy (for debugging)
@interface MyDebugCoder : NSCoder
+ (NSDictionary *)serializedJSONWithRootObject:(id<NSCoding, NSObject>)object;
@end
@implementation MyDebugCoder
{
NSMutableDictionary *_jsonRoot;
NSMutableArray *_values;
}
@NSProgrammer
NSProgrammer / CFRuntimeBase_struct_size.m
Created February 10, 2017 20:26
Determine the size of the CFRuntimeBase at runtime
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