Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Created March 13, 2011 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeabdullah/868549 to your computer and use it in GitHub Desktop.
Save mikeabdullah/868549 to your computer and use it in GitHub Desktop.
Customising object removal from NSArrayController
- (void)willRemoveObject:(id)object;
{
// Put your removal handling code here
}
- (void)removeObjects:(NSArray *)objects
{
// -removeObject: calls this method internally.
// Iterate the objects, reporting each one
for (id anObject in objects)
{
[self willRemoveObject:anObject];
}
[super removeObjects:objects];
}
- (void)removeObjectAtArrangedObjectIndex:(NSUInteger)index
{
// -removeObjectsAtArrangedObjectIndexes: calls this repeatedly
id object = [[self arrangedObjects] objectAtIndex:index];
[self willRemoveObject:object];
[super removeObjectAtArrangedObjectIndex:index];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment