Skip to content

Instantly share code, notes, and snippets.

@parpok
Created January 10, 2024 09:20
Show Gist options
  • Save parpok/b67ab56aa8136bf8726fe2b4b8e15f8a to your computer and use it in GitHub Desktop.
Save parpok/b67ab56aa8136bf8726fe2b4b8e15f8a to your computer and use it in GitHub Desktop.
#Preview {
do {
let config = ModelConfiguration(isStoredInMemoryOnly: true)
let container = try ModelContainer(for: Item.self, configurations: config)
let example = Item("Insert Item Parameters")
return PostView(Item: example)
.modelContainer(container)
}
catch {
fatalError("Something fucked up")
}
}
// This basically creates a in memory ModelConfiguration so that SwiftData can Show you the data. It's like with observables creating example objects but with SwiftData drip.
// Yes I stole that from tutorial - welcome to tutorial hell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment