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 | |
@main | |
struct MyTodoList: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} |
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 ContentView: View { | |
@Environment(\.managedObjectContext) var context | |
@FetchRequest(entity: Todo.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Todo.title, ascending: true)]) var todos: FetchedResults<Todo> | |
@State private var todoString: String = "" | |
var body: some View { | |
VStack { | |
HStack { | |
TextField("Add a Todo", text: $todoString) |
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 | |
@main | |
struct MyTodoList: App { | |
let context = DataStore.shared.persistentContainer.viewContext | |
var body: some Scene { | |
WindowGroup { | |
ContentView().environment(\.managedObjectContext, context) | |
} | |
} |
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 Foundation | |
import CoreData | |
class DataStore { | |
static let shared = DataStore() | |
let persistentContainer: NSPersistentContainer = { | |
let container = NSPersistentContainer(name: "MyDataModel") | |
container.loadPersistentStores { description, error in | |
if let error = error { |
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
0x163CeB9b2BA2e8Fa58B4F1544b7Df2d1028bD625 |
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
// Include http module | |
var http=require('http'); | |
// Get the ZIP code and email passed in by the request parameter sent to this script. | |
var zipCode=request.parameters.zipcode; | |
var email=request.parameters.email; | |
// Construct REST call to OpenWeatherMap API | |
var weatherService='http://api.openweathermap.org/data/2.5/weather?q='+zipCode+'&units=imperial'; | |
var callResult=http.request({'url': weatherService}); |