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
| #!/bin/bash -euo pipefail | |
| if [ ${#} -eq 0 ] | |
| then | |
| # read from STDIN | |
| MAYBE_GIT_HASH=$( cat ) | |
| else | |
| MAYBE_GIT_HASH="${1}" | |
| fi |
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
| extension NSFetchedResultsController { | |
| private func processChangesWithWillAccessValueForKey(notification: NSNotification) { | |
| guard let _ = self.fetchRequest.predicate, _ = self.fetchRequest.entity else { | |
| return | |
| } | |
| var matchingObjectIDs = self.insertedOrUpdatedObjectIDsMatchingFetchRequestInNotification(notification) | |
| self.managedObjectContext.performBlock({ | |
| let registeredObjectIDs = self.managedObjectContext.registeredObjects.map{$0.objectID} | |
| matchingObjectIDs.subtractInPlace(registeredObjectIDs) | |
| for matchingObjectID in matchingObjectIDs { |
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
| public extension NSManagedObjectContext { | |
| func addContextDidSaveNotificationObserver(center: NSNotificationCenter, handler: NSNotification -> ()) -> NSObjectProtocol { | |
| return center.addObserverForName(NSManagedObjectContextDidSaveNotification, object: self, queue: nil) { notification in | |
| handler(notification) | |
| } | |
| } | |
| func performMergeChangesFromContextDidSaveNotification(notification: NSNotification) { | |
| self.performBlock { |
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
| extension NSFetchedResultsController { | |
| func registerForCommitsToContext(context: NSManagedObjectContext, notificationCenter: NSNotificationCenter? = nil) -> NSObjectProtocol? { | |
| guard self.managedObjectContext != context else { | |
| return nil | |
| } | |
| let center = notificationCenter ?? NSNotificationCenter.defaultCenter() | |
| return center.addObserverForName(NSManagedObjectContextDidSaveNotification, object: context, queue: nil) { [weak self] notification in | |
| guard let strongSelf = self else { | |
| return | |
| } |
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
| final class SampleViewController: StoryboardBackedViewController { | |
| // Unfortunately this must be an IUO var, so that we can set the value after super.init | |
| private var member: Foo! | |
| // Proper dependency injection in a storyboard backed VC! | |
| init(foo: Foo) { | |
| super.init(storyboardIdentifier: "SampleViewControllerIdentifier") | |
| // We have to set the members *after* calling super.init, since it changes the instance of `self`. | |
| self.member = foo |
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
| /*----------------------------------------------------*/ | |
| #pragma mark - XCTAsserts | |
| /*----------------------------------------------------*/ | |
| XCTAssert(expression, format...); | |
| XCTAssertTrue(expression, format...); | |
| XCTAssertFalse(expression, format...); | |
| XCTAssertEqual(expression1, expression2, format...); | |
| XCTAssertNotEqual(expression1, expression2, format...); | |
| XCTAssertNil(expression, format...); |