Post

Replies

Boosts

Views

Activity

Xcode 12 CoreData Template
I'd love some help trying to understand the CoreDate template that you get when you create a new multiplatform app in Xcode 12 (beta 6 fwiw). In particular, I want to better understand what is happening in the initializer for the PersistenceController: init(inMemory: Bool = false) { container = NSPersistentContainer(name: "CoreDataTest2")         if inMemory {             container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")         }         container.loadPersistentStores(completionHandler: { (storeDescription, error) in             if let error = error as NSError? {                 fatalError("Unresolved error \(error), \(error.userInfo)")             }         })     } In particular, I'm wondering about two things: What purpose does the inMemory Bool serve? It's set to true when the template uses the SwiftUI preview, but when else would you set it to true? When would you set it to false? When it is set to true it then creates the persistent store description to a file URL with path "/dev/null" -- what does this mean? Do we need to set the Persistent Store Description to something else in production code?
1
0
1.6k
Sep ’20
Migrating existing SwiftUI apps to the new multi platform template
I have an iOS 13 app that I’m hoping to release soon that is written entirely in SwiftUI. If I was starting from scratch today, I’d obviously use the new multi platform template which looks awesome.... But since I’m not starting from scratch, what are the recommendations/best practices for existing apps? Is there a path for migrating existing apps to take advantage of the new app structure (below) when moving to iOS 14? @main struct HelloWorld: App { var body: some Scene { WindowGroup { Text(“Hello, world!”).padding() } } }
2
0
2.1k
Jun ’20