Re: Runtime Programmatic Entity Switching in CoreData
Re: Runtime Programmatic Entity Switching in CoreData
- Subject: Re: Runtime Programmatic Entity Switching in CoreData
- From: AJ <email@hidden>
- Date: Sun, 11 Jun 2006 14:31:07 -0400
I just implemented this and it works beautifully. A dozen lines of
custom code and I have a fully functioning data entry app to edit any
basic table of data I need.
So long .NET, it's been nice knowing you...
Objective-C / Cocoa / CoreData rocks.
On Jun 11, 2006, at 1:13 PM, mmalcolm crawford wrote:
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