我正在尝试使用NSUndoManager的prepareWithInvocationTarget。我想要像
这样的东西 [[self.undoManager prepareWithInvocationTarget:self] doSomethingWithObject:[self.aMutableArray objectAtIndex:0]]
在调用doSomethingWithObject
方法之前,不评估undo
的参数。换句话说,我不希望参数成为aMutableArray
的当前第一个元素,而是aMutableArray
时undo
的第一个元素。
我应该看一下NSInvocation或NSMethodSignature的特定部分吗?
答案 0 :(得分:0)
在任何方法调用中,它只是在哪里发生的问题。如果您现在不想评估[self.aMutableArray objectAtIndex:0]
,请不要将其包含在调用表达式中!相反,将调用表达式调用为该方法将调用[self.aMutableArray objectAtIndex:0]
的方法:
[[self.undoManager prepareWithInvocationTarget:self]
doSomethingWithObjectAtIndex:0];
...其中doSomethingWithObjectAtIndex:
是调用[self.aMutableArray objectAtIndex:0]
的位置。