This file contains 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
BOOL ProtocolContainsInstanceSelector(NSString *protocolName, SEL sel); | |
BOOL ProtocolContainsInstanceSelector(NSString *protocolName, SEL sel) | |
{ | |
Protocol *p = objc_getProtocol([protocolName cStringUsingEncoding:NSUTF8StringEncoding]); | |
// must check for both required = {YES, NO} | |
struct objc_method_description desc = protocol_getMethodDescription(p, sel, YES, YES); | |
BOOL contains = desc.name != NULL && desc.types != NULL; | |
if (!contains) { |
This file contains 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
NSString *HexNSStringFromBytes(uint8_t *bytes, NSUInteger count) { | |
char *hexCString = calloc(count * 2 + 1, sizeof(char *)); | |
static char hexLookup[] = "0123456789abcdef"; | |
NSMutableString* testString = [NSMutableString string]; | |
for (int i = 0; i < count; ++i) { | |
uint8_t fullByte = bytes[i]; | |
// each byte converts to two hex characters |
This file contains 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 <CommonCrypto/CommonDigest.h> | |
NSString *MD5StringFromBytes(uint8_t *bytes, NSUInteger count) | |
{ | |
uint8_t md5Bytes[CC_MD5_DIGEST_LENGTH]; | |
CC_MD5(bytes, count, md5Bytes); | |
// convert to hex string | |
static char hexLookup[] = "0123456789abcdef"; | |
char hexCString[CC_MD5_DIGEST_LENGTH * 2 + 1]; // each byte converts to two hex characters, plus null terminator |
This file contains 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
// UIInterfaceOrientationMask vs. UIInterfaceOrientation | |
// As far as I know, a function like this isn't available in the API. I derived this from the enum def for | |
// UIInterfaceOrientationMask. | |
inline BOOL OrientationMaskSupportsOrientation(UIInterfaceOrientationMask mask, UIInterfaceOrientation orientation) { | |
return (mask & (1 << orientation)) != 0; | |
} |
This file contains 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
Pod::Spec.new do |s| | |
s.name = "ReactiveCocoa" | |
s.version = "2.0.0dev" | |
s.summary = "A framework for composing and transforming sequences of values." | |
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source" | |
s.author = { "Josh Abernathy" => "josh@github.com" } | |
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :branch => '2.0-development' } | |
s.license = 'Simplified BSD License' | |
s.description = "ReactiveCocoa offers:\n" \ | |
"1. The ability to compose operations on future data.\n" \ |
This file contains 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
typedef struct { | |
Class class; | |
SEL sel; | |
} SelStruct; // not sure about the name SelStruct, but works for now | |
NSString *NSStringFromSelStruct(SelStruct s) { | |
return [NSString stringWithFormat:@"-[%@ %@]", s.class, NSStringFromSelector(s.sel)]; | |
} | |
- (void)testCache { |
This file contains 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)testInitWithDecimal { | |
Method m = class_getInstanceMethod([NSDecimalNumber class], @selector(initWithDecimal:)); | |
const char *types = method_getTypeEncoding(m); | |
// this will yield: | |
// +[NSMethodSignature signatureWithObjCTypes:]: unsupported type encoding spec '{?}' | |
NSMethodSignature *ms = [NSMethodSignature signatureWithObjCTypes:types]; | |
} |
This file contains 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
@class TKState, TKStateMachine; | |
typedef void (^LongStateBlock)(TKState *state, TKStateMachine *stateMachine); | |
static inline LongStateBlock Adapter(void(^block)()) { | |
void(^heapBlock)() = [block copy]; // forces block to be on heap rather than stack, a one-time expense | |
LongStateBlock longBlock = ^(TKState *s __unused, TKStateMachine *sm __unused) { | |
heapBlock(); | |
}; |
This file contains 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 BarrierOperation : NSOperation | |
@end | |
@interface BarrierQueue : NSObject | |
- (void)addOperation:(NSOperation *)op; |
This file contains 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
LEFT PARENTHESIS (U+0028, Ps): ( | |
RIGHT PARENTHESIS (U+0029, Pe): ) | |
LEFT SQUARE BRACKET (U+005B, Ps): [ | |
RIGHT SQUARE BRACKET (U+005D, Pe): ] | |
LEFT CURLY BRACKET (U+007B, Ps): { | |
RIGHT CURLY BRACKET (U+007D, Pe): } | |
LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, Pi): « | |
RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, Pf): » | |
TIBETAN MARK GUG RTAGS GYON (U+0F3A, Ps): ༺ | |
TIBETAN MARK GUG RTAGS GYAS (U+0F3B, Pe): ༻ |
OlderNewer