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
var exifOrientation: Int { | |
let exifOrientation: DeviceOrientation | |
enum DeviceOrientation: Int { | |
case top0ColLeft = 1 | |
case top0ColRight = 2 | |
case bottom0ColRight = 3 | |
case bottom0ColLeft = 4 | |
case left0ColTop = 5 | |
case right0ColTop = 6 | |
case right0ColBottom = 7 |
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
extension Date { | |
var timeAgoSimple: String { | |
let deltaSeconds = fabs(timeIntervalSince(Date())) | |
let deltaMinutes = deltaSeconds / 60.0 | |
if deltaSeconds < 60 { | |
return "\(Int(deltaSeconds))s" | |
} else if deltaMinutes < 60 { | |
return "\(Int(deltaMinutes))m" | |
} else if deltaMinutes < (24 * 60) { |
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 UIKit | |
extension UIViewController { | |
var segueIdentifiers: [String] { | |
return (self.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ $0.value(forKey: "identifier") as? String }) ?? [] | |
} | |
} |
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 ViewController: UIViewController { | |
var statusBarHidden: Bool = false { | |
didSet { | |
UIView.animate(withDuration: 0.25) { [weak self] in | |
self?.setNeedsStatusBarAppearanceUpdate() | |
} | |
} | |
} | |
override var prefersStatusBarHidden: Bool { |
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
// | |
// A -> B -> C -> D | |
// `keepFirst`: A | |
// `keepLast`: D | |
// | |
enum DebouncerType { | |
case keepFirst | |
case keepLast | |
} |
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 <XCTest/XCTest.h> | |
#import "Dispatcher.h" | |
#import <ReactiveObjC/ReactiveObjC.h> | |
@interface Dispatcher () | |
@property(nonatomic, assign) void (*dispatchMethod)(dispatch_queue_t, dispatch_block_t); | |
@property(nonatomic, strong) dispatch_queue_t queue; | |
@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
- (void)applicationDidEnterBackground:(UIApplication *)application { | |
@weakify(self); | |
self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ | |
@strongify(self); | |
[application endBackgroundTask:self.backgroundTaskIdentifier]; | |
self.backgroundTaskIdentifier = UIBackgroundTaskInvalid; | |
}]; | |
} | |
- (void)testApplicationDidEnterBackgroundExpirationHandler { |
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)testCacheSnapshotCombinations { | |
for (int i = 0; i < 32; i++) { | |
@autoreleasepool { | |
//Given: | |
UIImage *snapshotImage = [UIImage new]; | |
id image = OCMClassMock([UIImage class]); | |
OCMStub([image imageForView:OCMOCK_ANY]).andReturn(snapshotImage); | |
if (i & (1 << 0)) { | |
self.sut.bounds = CGRectMake(0, 0, 123, 456); |
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
With my case how I mock the static variable and I hope this can help you, here is my workaround: | |
For example, I have a static `count` value in production code: | |
``` | |
@implementation MyClass | |
static int _count = 0; | |
- (int)viewDidAppearCount { |
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
// | |
// ColdStartEventManagerTest.m | |
// InteractorTest | |
// | |
// Created by BBM on 28/3/18. | |
// | |
#import "ColdStartEventManager.h" | |
#import "AhoyReporterProtocol.h" |
OlderNewer