Hillegass の本で元に戻す/やり直しの章を読みました。ただし、彼はドキュメントベースのアプリケーションについてのみ説明します。本にあるコードとほぼ同じコードを使用していますが、以下のコードを使用すると「appController may not response to -undoManager」と表示されます。Undo Manager を明示的に作成する必要があることはわかっていますが、正確にはどうすればよいのでしょうか。順を追って説明をお願いします。ありがとう。
-(void)insertObject:(Accounts *)currentAccount inArrayOfAccountsAtIndex:(int)index { NSLog(@"Adding %@ to %@", currentAccount, arrayOfAccounts);
NSUndoManager *undo = [self undoManager];
[[undo prepareWithInvocationTarget:self]
removeObjectFromArrayOfAccountsAtIndex: index];
if(![undo isUndoing]){
NSLog(@"After the if(![undo isUndoing]) statement");
[undo setActionName:@"Insert Account"];
}
[arrayOfAccounts insertObject:currentAccount atIndex:index];
}