Managing Files with CoreData
Managing Files with CoreData
- Subject: Managing Files with CoreData
- From: Gordon Apple <email@hidden>
- Date: Sun, 18 Jul 2010 15:20:30 -0500
- Thread-topic: Managing Files with CoreData
I have a series of questions about using CoreData (iPad). Although CoreData
is supposedly easy to use, I have found it anything but. It is extremely
finicky and unforgiving. In fact, even with DTS support, I have never been
able to get NSFetchedResultsController to work using a cache. I do have
code working in a project retrofit, which I understand is probably the worst
way to start using CoreData.
My main entity has three references (one-to-one and one-to-many) to
identical entities defined as class "File" (a managed object). File is not
defined in the graphical model and is the only class (for the referenced
entities) defined in the code. File has a back reference, and two
attributes, a user-assigned name and a code-assigned uniqueID integer, the
latter of which forms the main part of the actual (internal) file name when
file access is required. Actual files are stored in their respective
subfolders of the documents folder for each defined File entity.
Question 1: The FRC is for the main entity and sorts on the main entity's
own name attribute. Is there anything is what I described above which could
be interfering with using an FRC cache?
Question 2: In the File class, what should I override to delete the actual
associated file when a file object is deleted from the database? (I'm
currently doing that separately when deleting the managed object.) Does
NSManagedObject's "dealloc" get called?
Question 3: The main entity has several NSNumbers. Should I write
translators for each of these to make life easier? (Why wasn't this built
into CoreData in the first place?)
Question 4: Is there any reason why you can't add additional methods (not
ivars) to Managed object code-files?
Question 5: I'm currently formulating file URLs in a separate FileManager
object. Is there a better way for CoreData to manage file references? Full
URLs could be problematic, if later systems change anything. Maybe partial
URLs/paths relative to the application's documents folder?
Comment: I have yet to see any sample code or writeups on using CoreData to
manage files, which seems like something that should be in common usage.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden