• 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
Custom NSArrayController - Dynamic Class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom NSArrayController - Dynamic Class?


  • Subject: Custom NSArrayController - Dynamic Class?
  • From: Brad Gibbs <email@hidden>
  • Date: Sat, 18 Jul 2009 09:01:51 -0700

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 (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


  • Follow-Ups:
    • Re: Custom NSArrayController - Dynamic Class?
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Where to release in UIView
  • Next by Date: Re: Custom NSArrayController - Dynamic Class?
  • Previous by thread: Re: Loading GC test bundles
  • Next by thread: Re: Custom NSArrayController - Dynamic Class?
  • Index(es):
    • Date
    • Thread