NSArrayController empty after changing entityName
NSArrayController empty after changing entityName
- Subject: NSArrayController empty after changing entityName
- From: Alexander Reichstadt <email@hidden>
- Date: Thu, 19 Feb 2009 11:38:46 +0100
Hi,
I want to dynamically change the entity an arraycontroller is using
depending on a selection in the UI.
When I do I either end up with undefinedkeys because the remaining
items from previous entity hang around, or if I explicitly say
setContent:nil it only works once, after that it stays empty and
doesn't fetch new items from the currently selected entity then.
NSString *zEntityname = [[[entitiesController selectedObjects]
objectAtIndex:0] valueForKey:@"name"];
NSEntityDescription *zEntity = [[[self managedObjectModel]
entitiesByName] objectForKey:zEntityname];
[databaseController setContent:nil];
[databaseController setEntityName:zEntityname];
id thisOne;
int i;
for (i=[[dataTable tableColumns] count];i>0;i--){
[dataTable removeTableColumn:[[dataTable tableColumns]
objectAtIndex:0]];
}
for (thisOne in [[zEntity attributesByName] allKeys]){
NSTableColumn *newColumn = [[NSTableColumn alloc]
initWithIdentifier:thisOne];
[[newColumn headerCell] setStringValue:thisOne];
[newColumn bind:@"value"
toObject:databaseController
withKeyPath:[NSString stringWithFormat:@"arrangedObjects.
%@",thisOne]
options:nil];
[dataTable addTableColumn:newColumn];
[newColumn release];
}
What do I have to do so this works?
Thanks
Alex
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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