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 FakeRecorder: BreadcrumbRecordable { | |
var testRecords: [Data] = [] | |
func saveRecord(_ data: Data!, streamName: String!) -> AWSTask<AnyObject>! { | |
testRecords.append(data) | |
return AWSTask() | |
} | |
func submitAllRecords() -> AWSTask<AnyObject>! { | |
return AWSTask() |
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 BreadcrumbLogger { | |
private let recorder: AWSFirehoseRecorder | |
init(recorder: AWSFirehoseRecorder = AWSFirehoseRecorder.default()) { | |
self.recorder = recorder | |
} | |
private func breadcrumbDictionary(breadcrumb: Breadcrumb) -> Dictionary<String, AnyObject?> { | |
let breadcrumbDictionary: Dictionary<String, AnyObject?> = [ |
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 BreadcrumbLogger { | |
let recorder = AWSFirehoseRecorder.default() | |
private func breadcrumbDictionary(breadcrumb: Breadcrumb) -> Dictionary<String, AnyObject?> { | |
let breadcrumbDictionary: Dictionary<String, AnyObject?> = [ | |
/* snip */ | |
:] | |
return breadcrumbDictionary | |
} | |
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
/// Schedules a timer on a queue when the view is loaded. | |
/// Also logs when deinit is invoked | |
class ViewControllerBase: UIViewController { | |
let timer:DispatchSourceTimer = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue(label: "q.q")) | |
deinit { | |
NSLog("deinit of \(NSStringFromClass(type(of: self)))") | |
} | |
override func viewDidLoad() { |
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
if let item = extensionContext?.inputItems.first as? NSExtensionItem, | |
let provider = item.attachments?.first as? NSItemProvider, | |
provider.hasItemConformingToTypeIdentifier("public.url") { | |
provider.loadItem(forTypeIdentifier: "public.url", options: nil) { (coder, error) in | |
let url = coder as? URL | |
NSLog("\(url)") | |
} | |
} |
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 LiveInstanceTracking | |
static NSHashTable *instances; | |
- (instancetype)init { | |
self = [super init]; | |
if (self) { | |
if (!instances) { | |
instances = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory capacity:1000]; | |
} |
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)lockWithCompletionBlock:(dispatch_block_t)completionBlock { | |
@synchronized(_lockSempahore) { | |
if (!self.locked) { | |
self.locked = YES; | |
[[NSOperationQueue mainQueue] addOperationWithBlock:completionBlock]; | |
return; | |
} | |
[self.blocksWaitingOnLockAcquisition addObject:completionBlock]; | |
} |
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)test_thatDeadlocks_whenRunAsPartOfALargerSuite { | |
SQRTransaction *transation = [self.testFixture createNewTransactionAndSaveContext]; | |
SQOTOpenTicket *associatedOpenTicket = [transaction.cart.openTicket SQOT_associatedOpenTicket]; | |
// ...verify setup... | |
XCTestExpectation *completionHandlerExpectation = [self expectationWithDescription:@"Completion handler called"]; | |
[self.openTicketsBroker lockOpenTicketForUserInteraction:associatedOpenTicket withCompletionBlock:^{ | |
// ... | |
[completionHandlerExpectation fulfill]; | |
}]; |