I think you need to use some sort of timing method if you don't want to be responding to each change. Something like this should work pretty well I think. The first line will cancel out the second one, as long as the method is called again within .1 seconds.
-(void)splitViewDidResizeSubviews:(NSNotification *)notification {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(respondToSubviewChange) object:nil];
[self performSelector:@selector(respondToSubviewChange) withObject:nil afterDelay:.1];
}
-(void)respondToSubviewChange {
NSLog(@"here");
// Do your work here.
}
BTW, if the class that this code is in is the delegate of the split view, then you don't need to register for this notification, it's automatically registered.
After Edit:
I did find another way that doesn't use any timing mechanism, but I don't know how robust it is. It relies on the fact that splitView:constrainMinCoordinate:ofSubviewAt: is called when you mouseDown in the divider, and again with mouseUp. It's also called once when the app first starts up (or maybe when the window the split view is in, is loaded, or something -- I didn't test it with more than one window). So, setting "timesCalled" to -1 (instead of 0) is to get the logic to ignore that first call when the app starts. Thereafter, the if clause evaluates to true on every other call (which would be on mouseUp) to the delegate method.
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex {
static int timesCalled = -1;
if (timesCalled % 2 == 1) {
NSLog(@"Do stuff");
// Do your work here.
}
timesCalled ++;
return 0 // 0 allows you to minimize the subview all the way to 0;
}