Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4004360
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:15:50+00:00 2026-05-20T08:15:50+00:00

My app needs to be able to disconnect from a server and connect to

  • 0

My app needs to be able to disconnect from a server and connect to another one at whim, which necessitates dumping whatever persistent store we have. Issue here is that releasing the ‘main’ managed object context means whatever objects in it that I have laying around fault, which causes all sorts of unexpected little issues and crashes.

Is there a better way to ‘reset’ my stack/managed objects littered around the program than just calling release on everything in my Core Data stack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:15:50+00:00Added an answer on May 20, 2026 at 8:15 am

    You need to close down you Core Data stack from the top down.

    1. Make sure that no managed objects are retained by any object other than the managed object context e.g. make sure the objects aren’t held in an array owned by a UI controller.
    2. Save the managed object context to clean up any loose ends.
    3. Fully release the context and nil it. The context should never be retained by more than one object e.g the app delegate, anyway.
    4. Send removePersistentStore:error: to the persistent store coordinator.
    5. Use standard file operations to delete the actual store file.

    Changing Core Data like this on the fly is difficult because Core Data isn’t just a little database hung off the side of the app. It is intended to serve as the apps entire model layer. Since Apple is really into Model-View-Controller design, then the model is the actual core of the program (hence Core Data’s name.) As such, you can’t really turn it on and off the way you would a mere SQL database.

    You might actually want to rethink your design so that you can change servers without having to shut down your entire data model. E.g. simply delete all managed objects associated with an unused server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app needs to build a buffer from all the selected cells on a
Many times, a Java app needs to connect to the Internet. The most common
I'm making an App that needs to be able to draw new graphics on
my app needs to both burn discs and create burn folders. i'm able to
I am working on a Facebook App that needs to be able to average
In my app users need to be able to enter numeric values with decimal
My app needs to play some audio files and I want to fade-out the
My current app needs to store address information for a user. I'm currently debating
My Cocoa app needs some small dynamically generated windows. How can I programmatically create
I have an app that needs to open a new window (in the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.