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
| // See http://www.opensource.apple.com/source/objc4/objc4-371.2/runtime/Accessors.subproj/objc-accessors.h | |
| extern void objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id newValue, BOOL atomic, BOOL shouldCopy); | |
| extern id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic); | |
| extern void objc_copyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL hasStrong); | |
| #define PSPDFAtomicRetainedSetToFrom(dest, source) objc_setProperty(self, _cmd, (ptrdiff_t)(&dest) - (ptrdiff_t)(self), source, YES, NO) | |
| #define PSPDFAtomicCopiedSetToFrom(dest, source) objc_setProperty(self, _cmd, (ptrdiff_t)(&dest) - (ptrdiff_t)(self), source, YES, YES) | |
| #define PSPDFAtomicAutoreleasedGet(source) objc_getProperty(self, _cmd, (ptrdiff_t)(&source) - (ptrdiff_t)(self), YES) | |
| #define PSPDFAtomicStructToFrom(dest, source) objc_copyStruct(&dest, &source, sizeof(__typeof__(source)), YES, NO) |
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
| // | |
| // PSPDFThreadSafeMutableDictionary.m | |
| // | |
| // Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is |
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/Foundation.h> | |
| @interface Node : NSObject | |
| @property (nonatomic) NSInteger identifier; | |
| @property (nonatomic, copy) NSString *value; | |
| + (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)value; | |
| @end | |
| @implementation Node | |
| + (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)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
| @interface UITableViewCell (FixConstraints) | |
| /* Finds any constraints that relate between a subview of the cell's content | |
| * view and the cell itself, and replaces them with otherwise identical constraints | |
| * that replace the cell with the content view. | |
| * | |
| * This works around a bug in Interface Builder where subviews added to a content | |
| * view have their constraints related to the cell itself and not the content view, | |
| * which can cause problems if you need to move the content view in any way (e.g. | |
| * swipe to delete). |
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
| //This validation method is completely generic; it dispatches to validate<Action>:, where <Action> is the item's action, duly initially-capitalized. | |
| - (BOOL) validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item { | |
| SEL action = [item action]; | |
| if (![self respondsToSelector:action]) { | |
| //We don't respond to the action, so unconditionally return NO. | |
| return NO; | |
| } | |
| /*Determine the selector of the message to send ourselves for actual validation. | |
| */ |
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
| NSUInteger PSPDFHashFromCGRect(CGRect rect) { | |
| return (*(NSUInteger *)&rect.origin.x << 10 ^ *(NSUInteger *)&rect.origin.y) + (*(NSUInteger *)&rect.size.width << 10 ^ *(NSUInteger *)&rect.size.height); | |
| } |
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
| After spending the better part of the month implementing date support | |
| in RethinkDB, Mike Lucy sent the team the following e-mail. It would | |
| have been funny, if it didn't cause thousands of programmers so much | |
| pain. Read it, laugh, and weep! | |
| ----- | |
| So, it turns out that we're only going to support dates between the | |
| year 1400 and the year 10000 (inclusive), because that's what boost | |
| supports. |
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
| extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE; | |
| extern BOOL DZApplicationUsesLegacyUI(void) | |
| { | |
| static dispatch_once_t onceToken; | |
| static BOOL legacyUI = NO; | |
| dispatch_once(&onceToken, ^{ | |
| uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED; | |
| if (dyld_get_program_sdk_version != NULL) { | |
| sdk = dyld_get_program_sdk_version(); |
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
| // Taken from http://PSPDFKit.com. This snippet is under public domain. | |
| #define UIKitVersionNumber_iOS_7_0 0xB57 | |
| BOOL PSPDFIsUIKitFlatMode(void) { | |
| static BOOL isUIKitFlatMode = NO; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| // We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
| if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
| isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
| } |