views:

34

answers:

1

I followed Apple's example for creating a managed object which btw was great...

http://developer.apple.com/cocoa/coredatatutorial/index.html

However I now want to know what "name" (filename) the user saved his data as. Does anyone know how to pull the filename from the core data object.

something like this would be great...

NSLog (@"the filename is %@", [coreData filename]);

Any ideas?

+1  A: 

Managed objects have no inherent relationship with files; there's nothing saying they ever need to go in to or come out of a file at all.

In the case that they are, you'll be wanting to look at the NSPersistentStore object eventually associated with your managed object through its managed object context and persistent store coordinator.

Jim Puls
I don't think the above example is a persistant store. When the user saves the managed object can I squirrel aways the filename somehow?
RW
RW: If your managed object actually does represent a single file conceptually, then sure, although I question the appropriateness of such a relationship (what happens when the user deletes the file outside your app?). But, more probably, everything Jim Puls said is true, and you should heed him. I'm not sure you've apprehended the concept of a managed object correctly; managed objects are essentially instances of the entities you construct in the model, and almost any app will have more than one managed object in a single document or library store.
Peter Hosey
I get the concept, however it doesnt help me do what I want. When a user prints data from my app, I want to place the filename associated with the doc on the printed page, but I don't know where to find that information.
RW