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
import SwiftUI | |
/// Modifier for detecting dismiss attempts via user swipe whilst those are disabled. | |
struct DismissAttemptDetectionModifier: ViewModifier { | |
/// Whether dismiss is to be disabled. When `false`, the view modifier has no effect. | |
let dismissDisabled: Bool | |
/// Called if the sheet is dragged down in a fashion considered to be a dismiss attempt, whilst `dismissDisabled` is `true`. | |
let onDismissAttempted: () -> Void | |
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
import CoreData | |
import PlaygroundSupport | |
// Requires a momd called "TestModel" be added to the Resources directory of the playground. | |
// This can be obtained by creating a model in an iOS app, building, and copying the momd directory | |
// from the resulting Products directory into this playground's Resources directory. | |
// The model has a single entity called "Entity" with a single optional string attribute called "testAttribute". | |
// There are no relationships in the model. |
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
import CoreData | |
import PlaygroundSupport | |
extension NSManagedObjectContext { | |
func childContext(concurrencyType: NSManagedObjectContextConcurrencyType = .mainQueueConcurrencyType) -> NSManagedObjectContext { | |
let childContext = NSManagedObjectContext(concurrencyType: concurrencyType) | |
childContext.parent = self | |
return childContext | |
} | |
} |
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
import XCPlayground | |
import CSVImporter | |
class Row { | |
let cell1: String | |
let cell2: String | |
let cell3: String | |
init(cell1: String, cell2: String, cell3: String){ | |
self.cell1 = cell1 | |
self.cell2 = cell2 |
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
/** | |
A CompoundFetchedResultsController is a wrapper of a number of inner NSFetchedResultsControllers. | |
The wrapper flattens the sections produced by the inner controllers, behaving as if all sections | |
were fetched by a single controller. Additionally, change notifications are mapped before being | |
passed to the optional NSFetchedResultsControllerDelegate property, so that the section indices | |
in the notifications reflect the flattened section indicies. | |
Example use case: a table where sections should be ordered in mutually opposing ways. E.g., if | |
section 1 should be ordered by propery A ascending, but section 2 should be ordered by property A | |
descending. In this case, two controllers can be created - one ordering ascending, the other de- |