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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to