Post

Replies

Boosts

Views

Activity

Reply to Using Core Data with SwiftUI App Protocol
@42Wowbaggers Did you use lazy var persistentContainer? If so, then making it non-lazy should work. While this will indeed silence the error, it'll also mean that a new persistent container is created each time persistentContainer is accessed. lazy is used to make sure the closure is only ever executed once. IMO the best approach would be to move the initialisation of the container into a private init()—so the store can only be accessed through the shared singleton—and make persistentContainer immutable. class PersistentStore { 		static let shared = PersistentStore() 		let persistentContainer: NSPersistentContainer 		private init() { 				self.persistentContainer = // ... 		} }
Jul ’20