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 8346489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:01:56+00:00 2026-06-09T07:01:56+00:00

Phew, sorry for the long title. I have a single Managed Object Context where

  • 0

Phew, sorry for the long title.

I have a single Managed Object Context where I am storing songs derived from two different locations. I get some of the songs from the persistent storage on the phone (using Core Data), and I pull some of the songs from an online database. Both of the songs are of the same MananagedObject subclass. I would like both of these songs to be in a single context because I would like them both to show up on a table view connected with an NSFetchedResultsController.

The problem occurs when I would like to save one of the songs. I don’t want to save all of the songs that I pulled from the online database to the phone. I just want to save the single song, so a simple [moc save] doesn’t work. The other issue is that after I save the single song, I still want the songs pulled from online to be in the context (but again, not saved). I believe I have a couple of different options:

1) Is it possible to have an NSFetchedResults controller connected to multiple contexts?

2) I could move all of the songs pulled from the online database into a separate temporary context, save in the original context, and then move all of the songs back. (see: How do I copy or move an NSManagedObject from one context to another?)

3) Remember all of the key-value pairs for the online songs, delete the online songs from the context, save the original context, insert all of the online songs back into the original context based off of the saved key-value pairs.

4) I am a huge n00b and am missing something easier.

Thanks!

  • 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-06-09T07:01:58+00:00Added an answer on June 9, 2026 at 7:01 am

    I think the easiest thing to do would be to have a second NSPersistentStore attached to your persistent store coordinator. You can have that store be an in-memory store, and store all your “online” results in that (temporary) store. You can specify which store a newly-inserted object should be saved in with assignObject:toPersistentStore:. Once you’ve done this, you can save freely, since the “save” will only happen to memory for your online songs.

    Then, when you want to move a song from the online set to the permanent set, just delete it and re-insert it, assigning the new object to your permanent persistent store with the same method.

    This will let you use a single NSManagedObjectContext attached to your NSPersistentStoreCoordinator, which will see objects from both of the NSPersistentStores.

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

Sidebar

Related Questions

phew! That was a long title. I'm reading WROX' book on Professional JavaScript for
I have a python program which takes input from stdin. Now, I've to write
Phew where do I begin... OK, I have a list that I have to
I have a long NSString I want to display over a couple of pages.
Hey there, I have a page with the jQuery Draggable() enabled on #person and
In .NET, I need a way to compare two files. I thought of a
I have a VB6 application that still references some old VB5 libraries (dll, vbr,
Background: I have started Android recently. I want to make an application for Android
I have a website registration page, and I'm trying to compile a list of
Right now I have class MyParamClass { all the parameters I need to pass

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.