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
func memoize<T: Hashable, U>( body: ((T)->U, T)->U ) -> (T)->U { | |
var memo = Dictionary<T, U>() | |
var result: ((T)->U)! | |
result = { x in | |
if let q = memo[x] { return q } | |
let r = body(result, x) | |
memo[x] = r | |
return r | |
} | |
return result |
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 NSProcessInfo (WMLCompatibility) | |
+ (void)wml_addSelector:(SEL)originalSelector implementedWithSelector:(SEL)newSelector { | |
if (![self instancesRespondToSelector:originalSelector]) { | |
Method newMethod = class_getInstanceMethod(self, newSelector); | |
class_addMethod(self, originalSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)); | |
} | |
} | |
+ (void)load { |
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
# You can use lookup mode to retrieve your app’s current metadata. | |
# Lookup mode will create an App Store package at the set destination. | |
# The package name will be the app's SKU with the .itmsp extension. | |
# For example, if your app’s SKU is “myapp1” on iTunes Connect, | |
# your filename would be myapp1.itmsp. The metadata.xml file within | |
# the App Store package contains the app's metadata. | |
iTMSTransporter -m lookupMetadata | |
-u USERNAME -p PASSWORD | |
-vendor_id APP_SKU -subitemtype [InAppPurchase | GameCenterLeaderboard | GameCenterAchievement] |
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 ZTSDynamicProxy : NSProxy | |
+ (instancetype)dynamicProxyWithObject:(id)object; | |
@property (nonatomic, strong) id zts_object; | |
@end |
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 Calculator : NSObject | |
- (NSNumber *)methodA; | |
- (NSNumber *)methodB; | |
@end | |
@implementation Calculator | |
- (NSNumber *)methodA { | |
return [self methodB]; | |
} | |
- (NSNumber *)methodB { |
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 NSString *const WMLTemplatedAnimationColorFillLayerName = @"WMLTemplatedAnimationFillLayerName"; | |
static NSString *const WMLTemplatedAnimationMaskLayerName = @"WMLTemplatedAnimationMaskLayerName"; | |
@interface UIImageView (WMLTemplatedAnimation) | |
- (void)wml_startAnimating; | |
- (void)wml_stopAnimating; | |
@end |
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
Class mock = mockClass([NSProcessInfo class]); | |
[mock processInfo]; | |
[verify(mock) processInfo]; |
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 mock = mockClass([NSProcessInfo class]); | |
[mock processInfo]; | |
[verify(mock) processInfo]; |
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)debugQuickLookObject { | |
NSUInteger width = 100 + (([self hash] >> 4) & 0xFF); | |
NSUInteger height = 100 + (([self hash] >> 8) & 0xFF); | |
return [NSURL URLWithString:[NSString stringWithFormat:@"http://placekitten.com/%tu/%tu", width, 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
@interface ZTSCameraControllerHelper () | |
@property (nonatomic, assign, getter = isIdleTimerDisabled) BOOL idleTimerDisabled; | |
@end | |
@implementation ZTSCameraControllerHelper | |
+ (instancetype)sharedInstance { | |
static ZTSCameraControllerHelper *instance; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ |