• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSArrayController empty after changing entityName
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Memory Leak, part I
  • Next by Date: Cocoa, Finder Preferences & Blank Media (CD-R etc) ...
  • Previous by thread: FOLDERS and document based apps (Open Recent)
  • Next by thread: Cocoa, Finder Preferences & Blank Media (CD-R etc) ...
  • Index(es):
    • Date
    • Thread