我正在为我的应用程序构建撤销/重做功能。我正在使用NSUndoManager的NSInvocation方法。iPhone - NSUndoManager + NSInvocation +对象发布=崩溃
这是我建立调用
NSNumber *firstState = [NSNumber numberWithInt:fsNumber];
NSInvocation *initialState = [self restoreStateInvocation:firstState];
// ... the code continues...
这些方法关乎
- (NSInvocation *) restoreStateInvocation:(NSNumber*)number {
NSMethodSignature *executeMethodSignature = [self methodSignatureForSelector:
@selector(makeUNDO:)];
NSInvocation *moveInvocation = [NSInvocation invocationWithMethodSignature: executeMethodSignature];
[moveInvocation setTarget:self];
[moveInvocation setSelector:@selector(makeUNDO:)];
[moveInvocation setArgument:&number atIndex:2];
return moveInvocation;
}
- (void) makeUNDO:(NSNumber*)number {
int num = (int)[number intValue];
// code crashes at this line... number appears to be deallocated at this time
//
...
}
当撤消/恢复呼叫的初始化状态上makeUNDO的第一行中的应用程序崩溃,如指出的代码。
如何保留号码而不漏水?
谢谢。
@Digital机器人:检查更新的答案。 – Jhaliya 2011-05-31 04:14:37