Re: Runtime Programmatic Entity Switching in CoreData
Re: Runtime Programmatic Entity Switching in CoreData
- Subject: Re: Runtime Programmatic Entity Switching in CoreData
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 11 Jun 2006 10:13:37 -0700
On Jun 11, 2006, at 8:02 AM, AJ wrote:
I've got a nicely working window built that works to edit the
records of one of the entities, and I'm considering going down the
road of writing code to allow this single window to edit other
entities that have identical structures.
These are essentially "reference tables" that have identical
structures. Things like "PersonType", "CompanyType", etc., that
all fundamentally have an ID, a name, a note, and a few other
common fields.
I'd rather not build a dozen identical windows to edit all these,
so I imagine writing code to:
1. make sure all changes to the CoreData entities in the current
window are committed to the persistent store.
2. either create new array controllers programmatically - or
manipulate the ones already instantiated - to reference a different
CoreData entity.
3. tell the array controllers and the window to "rebind" or
"refresh" so that editing can continue for the new entity type.
Provided that names of the set of properties you bind are shared by
all the entities, then there should be no problem -- KV{C,O,B} just
uses the property names...
Then you can switch the name of the entity the array controller
displays and reload:
- (IBAction)showPersonEntity:sender;
{
[arrayController setEntityName:@"Person"];
[arrayController fetch:self];
}
mmalc
_______________________________________________
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