• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Data: where is the default store in a CD-Document-Based-App?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: where is the default store in a CD-Document-Based-App?


  • Subject: Core Data: where is the default store in a CD-Document-Based-App?
  • From: Peter Laurens <email@hidden>
  • Date: Tue, 23 Aug 2005 15:04:02 +0100

Hi,

I'm building my first Core Data app, so be gentle ;)

Problem:
------------

I had a relatively simple Core Data Document Based App all set up. Naturally XCode sets me up a decent starting point, and I just draw my data model and everything is handled for me. This was great - and obviously there's a persistent store set up automagically for me, because I can save my data in my app without any work. Well - I say 'obviously' but this is an assumption because... I can't seem to 'find this original persistent store...

I do :

- (void)windowControllerDidLoadNib:(NSWindowController *) windowController
{
NSPersistentStoreCoordinator *documentStoreCoordinator = [[self managedObjectContext] persistentStoreCoordinator];
NSLog(@"Number of stores is %d", [[documentStoreCoordinator persistentStores]count]);
}


In MyDocument, and NSLog prints '0'. Whereas I would expect it to say '1'. Because there's something there saving my stuff (unless I'm imagining things).



Why do I want to know about this?:
-----------------------------------------------

Well, I'd like to know more about this 'default' automagic store because as my app progressed I had need to create an in-memory store for a certain type of object that I don't need to save. That was all very simple to do.

But seems to have thrown my app a bit of a wobbly.

After I create the in-memory store ([documentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:&error];) nothing gets saved when I call the 'save' command from the File menu in my app.

So I assume that everything is going, by default, into the in-memory store. Which has taken precedence for use over the 'default' original store that was used before I started messing with the persistent stores in code.

So I'd like a way to call assignObject:toPersistentStore: and assign all things I want to whatever it is that's set up to store my things for me in a fresh Core Data app (the store I can't manage to 'find') - if that makes sense.


One thing I did try was just to create another store to handle the stuff that needs to be saved - duplicating the automatically provided CD-Document-Based-App functionality by making my own persistent store for stuff to save, as WELL as the in-mem store for stuff I didn't want saved. This had me quickly tying myself in knots because such a store needs an URL for its store - and in a document based app I'll need to manually make a different URL for each store to make sure documents don't step on each other's stores, and handle the cleanups etc. etc. etc. Well... it just seemed like a totally wrong and non- Cocoa thing to do.





@finally: ------------

All simple stuff for many of ya I'm sure. But any help offered on getting my head around these issues would be so very gratefully received...

Thanks in advance!

- Pete
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Core Data: where is the default store in a CD-Document-Based-App?
      • From: Melissa Turner <email@hidden>
  • Prev by Date: Getting first responder state for a custom view enclosed in a NSTabView ?
  • Next by Date: Re:Newbie question
  • Previous by thread: Re: Getting first responder state for a custom view enclosed in a NSTabView ?
  • Next by thread: Re: Core Data: where is the default store in a CD-Document-Based-App?
  • Index(es):
    • Date
    • Thread