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 SwiftUI | |
import CoreData | |
struct FetchedObjects<T, Content>: View where T : NSManagedObject, Content : View { | |
// MARK: - Properties | |
let content: ([T]) -> Content | |
var request: FetchRequest<T> |
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 SwiftUI | |
struct StudentsView: View { | |
@State var predicate: NSPredicate = NSPredicate(format: "firstName contains[c] %@", "Joe") | |
var body: some View { | |
VStack { | |
FetchedObjects( | |
predicate: self.predicate, |
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
let endpoint = Pinball.Endpoint( | |
method: .get, | |
host: 'baconipsum.com', | |
paths: ["api"], | |
queries: [ | |
Pinball.Query(key: "type", value: "meat-and-filler") | |
] | |
) |
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
try? URLSession.shared.dataTask(for: endpoint) { (data, response, error) in | |
// Do something with the response… | |
} | |
// Or using Combine… | |
if #available(OSX 10.15, *) { | |
let publisher = try? URLSession.shared.dataTaskPublisher(for: endpoint) | |
// Do something with the Combine Publisher |
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 DocExampleDocument: ReferenceFileDocument { | |
// ... | |
} |
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
func snapshot(contentType: UTType) throws -> String { | |
return self.text | |
} | |
func write(snapshot: String, to fileWrapper: inout FileWrapper, contentType: UTType) throws { | |
let data = snapshot.data(using: .utf8)! | |
fileWrapper = FileWrapper(regularFileWithContents: data) | |
} |