UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: CoreData persistentStore location question

Forums > SwiftUI

Hello. I have a question about the Xcode CoreData template I'm hoping that someone can answer. It includes the following:

if inMemory {
        container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}

That has been fine as I've been working on my first post-"100 Days Of SwiftUI" fun project and testing things out, but I'm getting closer to the end and I have a feeling that "/dev/null" is not where this should go, but I'm not sure what path to change this to. Anyone have any idea?

2      

That is exactly what you want for a persistent store that is in memory only. It ensures that nothing will actually be persisted and each time you run the app in the simulator it will start with a fresh store.

You obviously wouldn't want to set inMemory to true in production, though.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.