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
struct Constants { | |
let leftPadding: CGFloat | |
let rightPadding: CGFloat | |
static func defaultConfiguration() -> Constants { /* init */ } | |
static func compactConfiguration() -> Constants { /* init with different stuff */ } | |
} |
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
@interface TMObjectThatHasLotsOfDependenciesInjected : NSObject | |
- (nonnull instancetype)initWithDependency:(TMDependency * __nonnull)dependency | |
anotherDependency:(TMOtherDependency * __nonnull)anotherDependency NS_DESIGNATED_INITIALIZER; | |
/// option 1: break inheritance | |
- (nullable instancetype)init __attribute__((unavailable("Use initWithDependency:anotherDependency: instead"))); | |
@end |
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
// Follow up to - https://gist.github.com/paulrehkugler/11063725 | |
BOOL baseCaseCondition = NO; // obviously this should be data driven, not hardcoded | |
typedef void (^RecursiveBlock)(void (^)()); | |
RecursiveBlock aRecursiveBlock; | |
aRecursiveBlock = ^(RecursiveBlock block){ | |
if ((baseCaseCondition) && block) | |
{ |
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
// trying to make a block pointer | |
typedef void (^DoingBadStuffWithBlocks)(); | |
DoingBadStuffWithBlocks *theCompilerHatesThis = &^{ | |
if (false) | |
{ | |
*theCompilerHatesThis(); | |
} | |
}(); |
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
// SomeProtocol.h | |
@protocol SomeProtocol <NSObject> | |
- (void) protocolMethod; | |
@end | |
// NSObject+SomeProtocolDefaultImplementation.h | |
@interface NSObject(SomeProtocolDefaultImplementation) |
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
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 | |
#define IOS7_CODE_WITH_FALLBACK(iOS7_code, other_code) \ | |
do { \ | |
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {\ | |
iOS7_code \ | |
}\ | |
else { \ | |
other_code \ | |
} \ |
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
// | |
// NSObject+PRKeyValueObserving.h | |
// PRKeyValueObserving | |
// | |
// Created by Paul Rehkugler on 3/8/14. | |
// Copyright (c) 2014 Paul Rehkugler. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
- (BRYDescriptionBuilder *)appendInteger:(NSInteger)integer withName:(NSString *)name { | |
#if defined(__LP64__) && __LP64__ | |
return [self appendString:[NSString stringWithFormat:@"%li", integer] withName:name]; | |
#else | |
return [self appendString:[NSString stringWithFormat:@"%i", integer] withName:name]; | |
#endif | |
} | |
- (BRYDescriptionBuilder *)appendUnsignedInteger:(NSUInteger)unsignedInteger withName:(NSString *)name { | |
#if defined(__LP64__) && __LP64__ |
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
/* MyModelObject.h */ | |
@interface MyModelObject : NSObject | |
// this data is "publicly" immutable | |
@property (nonatomic, readonly) NSArray *someData; | |
@end |
NewerOlder