I have a Core Data app and several tables for adding various entities. I want to add an index to each new object so I can sort them after fetching. I've been using a custom NSArrayController and overriding the addObject:, insertObject: atArrangedObjectIndex:, and removeObject: methods to add or update the indices as I go, using, for example:

- (void)addObject:(Floor *)object {
        [super addObject:object];
object.index = [NSNumber numberWithInt:[[self arrangedObjects] indexOfObject:object]];
        NSLog(@"Added %@", [object description]);
}

This means that I need a custom NSArrayController for each entity. Is there a way to make the entity name dynamic? In other words, can I ask the array controller for the name of the entity it's managing, so I only need one custom NSArrayController subclass to manage this for several different entity types? I guess I'm looking for a way to replace the argument (Floor *) from the example above with something like:

[[[self arrangedObjects] objectAtIndex:0] class]

If I use id, the code doesn't know that the object being added should have an index.

Thanks.

Brad
_______________________________________________

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