Of all the things that I would expect to support blocks, NSUndoManager curiously does not seem to do so. Is there some inherent reason for this, or has Apple simply not gotten around to modernizing this bit of API?
In particular I would like to define a method on NSObject,
- (void)performBlock {
void (^block)(void) = (id)self;
block();
}
in order to be able to call,
[[undoManager prepareWithInvocationTarget:^{
NSLog( @"hello world" );
}] performBlock];
Have I missed something? Is there anything wrong with this?
(Inspired by an 2009 Mike Ash article, which recommends not defining methods on blocks. I left a comment there, too.)