This file contains hidden or 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
| @interface UIView (MPAdditions) | |
| @end | |
| @implementation UIView (MPAdditions) | |
| - (id)debugQuickLookObject { | |
| if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) { | |
| return nil; | |
| } | |
This file contains hidden or 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; | |
| @import CoreGraphics; | |
| typedef struct __attribute__((objc_boxable)) CGPoint CGPoint; | |
| typedef struct __attribute__((objc_boxable)) CGSize CGSize; | |
| typedef struct __attribute__((objc_boxable)) CGRect CGRect; | |
| typedef struct __attribute__((objc_boxable)) CGVector CGVector; | |
| int main(int argc, const char * argv[]) { | |
| @autoreleasepool { |
This file contains hidden or 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
| #!/bin/bash | |
| # Exit the script immediately on error | |
| set -e | |
| # We'll work in /tmp | |
| cd /tmp | |
| # Clone mach_override unless we already have it | |
| if [ ! -d mach_override ]; then |
This file contains hidden or 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
| // clang -cc1 -analyzer-checker-help | |
| // OVERVIEW: Clang Static Analyzer Checkers List | |
| // USAGE: -analyzer-checker <CHECKER or PACKAGE,...> | |
| // | |
| // CHECKERS: | |
| // alpha.core.BoolAssignment Warn about assigning non-{0,1} values to Boolean variables | |
| // alpha.core.CallAndMessageUnInitRefArg | |
| // Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers, and pointer to undefined variables) | |
| // alpha.core.CastSize Check when casting a malloc'ed type T, whether the size is a multiple of the size of T | |
| // alpha.core.CastToStruct Check for cast from non-struct pointer to struct pointer |
This file contains hidden or 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
| static void PSPDFFixiOS12AccessibilityTestCrash(void) { | |
| let accessibilityLoaderClass = NSClassFromString(@"UIAccessibilityInformationLoader"); | |
| let accessibilitySEL = NSSelectorFromString(@"_loadAccessibilityInformationOnMainThread:"); | |
| __block IMP originalIMP = pspdf_swizzleSelectorWithBlock(accessibilityLoaderClass, accessibilitySEL, ^(id _self, BOOL onMainThread) { | |
| @try { | |
| ((void (*)(id, SEL, BOOL))originalIMP)(_self, accessibilitySEL, onMainThread); | |
| } @catch (NSException *exception) { | |
| NSLog(@"Exception received: %@", exception); | |
| if ([exception.name isEqualToString:NSInvalidArgumentException] && [exception.reason containsString:@"_accessibilityLoadAccessibilityInformation"]) { | |
| NSLog(@"Ignoring IOS 12b5 weirdness..."); |
This file contains hidden or 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
| extension UICollectionViewFlowLayout { | |
| typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value) | |
| private var delegate: UICollectionViewDelegateFlowLayout? { | |
| return collectionView?.delegate as? UICollectionViewDelegateFlowLayout | |
| } | |
| func retrieve<Key, Value>( |
This file contains hidden or 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
| // | |
| // PSPDFGenerics.h | |
| // PSPDFFoundation | |
| // | |
| // PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com. | |
| // Try it today using our free PDF Viewer app: https://pdfviewer.io/ | |
| // | |
| // This file is MIT licensed. | |
| /** |
This file contains hidden or 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
| COMPACT WIDTH (stacked view) | |
| - 320 x 568 pt | |
| -> iPhone 5, 5s | |
| - 320 x 768 pt | |
| -> iPad 9.7" Split Landscape 2/3 right | |
| - 320 x 834 pt | |
| -> iPad 10.5" Split Landscape 2/3 right | |
| - 320 x 1024 pt | |
| -> iPad 9.7" Split Portrait right |
This file contains hidden or 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
| // Compile with clang -framework Foundation sethack.m | |
| #import <Foundation/Foundation.h> | |
| #import <objc/runtime.h> | |
| /* | |
| CFHashBytes from http://www.opensource.apple.com/source/CF/CF-1153.18/CFUtilities.c | |
| */ | |
| #define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1; |
This file contains hidden or 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
| CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget) | |
| { | |
| // first try to match width | |
| CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit); | |
| // if we scale the height to make the widths equal, does it still fit? | |
| if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) { | |
| return s; | |
| } | |
| // no, match height instead | |
| return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit); |
OlderNewer