func registerUndo (withTarget : Any, selector: Selector, object: Any?)
func prepare(withInvocationTarget : Any) -> Any
Availability 有効性
Technology
func registerUndo<TargetType >(withTarget target: TargetType , handler: @escaping (TargetType ) -> Void
) where TargetType : AnyObject
target
The target of the undo operation. 取り消し操作の目標。
The undo manager maintains an unowned reference to the target
to prevent retain cycles.
アンドゥマネージャは、target
に対する非所有参照を保守して、保持循環を防ぎます。
handler
A closure to be executed when an operation is undone. 操作が取り消される時に遂行されるクロージャ。
The closure takes a single argument, the target of the undo operation. ただ1つだけの引数、取り消し操作の目標、をとるクロージャ。
Use register
to register a closure as an undo operation on the undo stack. The registered closure is then executed when undo
is called and the undo operation occurs. The target needs to be a reference type so that its state can be undone or redone by the undo manager.
register
を使って、クロージャを取り消し操作として取り消しスタック上に登録してください。登録されたクロージャは、それからundo
が呼び出されて取り消し操作が発生する時に遂行されます。目標は参照型である必要があります、そうすることでそれの状態は取り消しまたはやり直しされることがアンドゥマネージャによって可能です。
The following example demonstrates how you can use this method to register an undo operation that adds an element back into a mutable array. 以下の例は、どのようにあなたがこのメソッドを使って、ある要素を可変配列へと加えて戻すある取り消し操作を登録できるかを実演します。
To avoid retain cycles with the target, operate on the closure parameter rather than on variables in an outer scope that reference the same target. For example, in the code listing above, the closure operates on the $0
parameter rather than directly on bouquet
.
目標との保持循環を防ぐために、クロージャパラメータ上で演算してください、同じ目標を参照する外部スコープの中の変数上でではなく。例えば、上でのコード出力において、クロージャは$0
パラメータ上で演算します、直接にbouquet
上でではなく。
func registerUndo (withTarget : Any, selector: Selector, object: Any?)
func prepare(withInvocationTarget : Any) -> Any