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
@implementation XCDUUID | |
+ (void) load | |
{ | |
// query runtime if NSUUID class already exists, if so => done | |
if (objc_getClass("NSUUID")) | |
{ | |
return; | |
} | |
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
- (void)pauseLayer:(CALayer *)layer { | |
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; | |
layer.speed = 0.0f; | |
layer.timeOffset = pausedTime; | |
} | |
- (void)resumeLayer:(CALayer *)layer { | |
CFTimeInterval pausedTime = [layer timeOffset]; | |
layer.speed = 1.0; | |
layer.timeOffset = 0.0; |
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
// -*- truncate-lines: t; -*- | |
// OPTION(var, env, help) | |
OPTION( PrintImages, OBJC_PRINT_IMAGES, "log image and library names as they are loaded") | |
OPTION( PrintImageTimes, OBJC_PRINT_IMAGE_TIMES, "measure duration of image loading steps") | |
OPTION( PrintLoading, OBJC_PRINT_LOAD_METHODS, "log calls to class and category +load methods") | |
OPTION( PrintInitializing, OBJC_PRINT_INITIALIZE_METHODS, "log calls to class +initialize methods") | |
OPTION( PrintResolving, OBJC_PRINT_RESOLVED_METHODS, "log methods created by +resolveClassMethod: and +resolveInstanceMethod:") | |
OPTION( PrintConnecting, OBJC_PRINT_CLASS_SETUP, "log progress of class and category setup") |
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
FILE SPACING: | |
# double space a file | |
sed G | |
# double space a file which already has blank lines in it. Output file | |
# should contain no more than one blank line between lines of text. | |
sed '/^$/d;G' |
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/sh | |
# Combined all static libaries in the current directory into a single static library | |
# It is hardcoded to use the i386, armv7, and armv7s architectures; this can easily be changed via the 'archs' variable at the top | |
# The script takes a single argument, which is the name of the final, combined library to be created. | |
# | |
# For example: | |
# => combine_static_libraries.sh combined-library | |
# | |
# Script by Evan Schoenberg, Regular Rate and Rhythm Software |
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 UIKit | |
/// Used to create a layout guide that pins to the top of the keyboard | |
final class KeyboardLayoutGuide { | |
private let notificationCenter: NotificationCenter | |
private let bottomConstraint: NSLayoutConstraint |
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
int outCount; | |
objc_property_t *properties = class_copyPropertyList([MyObject class], &outCount); | |
for(i = 0; i < outCount; i++) { | |
objc_property_t property = properties[i]; | |
const char *c_attributes = property_getAttributes(property); | |
printf("%s", c_attributes); | |
} | |
free(properties); | |
属性类型 name值:T 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
- (id)initWithCoder:(NSCoder *)aDecoder { | |
if (self = [super init]) { | |
unsigned int outCount; | |
Ivar * ivars = class_copyIvarList([self class], &outCount); | |
for (int i = 0; i < outCount; i ++) { | |
Ivar ivar = ivars[i]; | |
NSString * key = [NSString stringWithUTF8String:ivar_getName(ivar)]; | |
[self setValue:[aDecoder decodeObjectForKey:key] forKey:key]; | |
} | |
} |
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
NS_ASSUME_NONNULL_BEGIN | |
/** | |
A proxy used to hold a weak object. | |
It can be used to avoid retain cycles, such as the target in NSTimer or CADisplayLink. | |
sample code: | |
@implementation MyView { | |
NSTimer *_timer; |
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; | |
@interface NSObject (ThreadSafeProxy) | |
- (instancetype)threadSafe; | |
@end | |