IT English Collection(26) of Undo manager

2024-05-03 16:32

本文主要是介绍IT English Collection(26) of Undo manager,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1 前言

  本节主要介绍了撤销和重做的原理,使用方法和主要用处。

  转载请注明出处:http://blog.csdn.net/developer_zhang

2 详述

2.1 原文

  An undo manager is a framework object for recording changes to object state and later undoing those changesupon user request. The undo manager, which is an instance of the NSUndoManager class,conducts both undo and redo operations. An undo operationreverts a change to a property of an object; a redo operation restores theoriginal value if an undo operation has taken place. The ability to perform undo and redo operations is avaluable and differentiating feature of applications,especially those that allow users to change dataextensively.

  You obtain an undo manager through the undoManager property of UIResponder (iOS) or by calling the undoManager method of NSResponder (OS X). Every window of an application provides a default undo manager, although you can create private ones for specific contexts.

Undo and Redo Operations Send Messages to the Changed Object


  You must register an undo operation with the undo manager. When the undo manager executes the operation, it sends a messagecomposed from severalcomponents supplied in registration:

  The object to receive the message. The receiving object is typically an object having a property whose value has changed.
  The signature of the method to invoke. The signature often identifies a setter accessor method.
  The argument of the message. The argument is typically the previous value of the property that has changed. For redo operations, the argument is the changed value.
An undo manager collects all undo operations that occur within a single cycle of a run loop such as the application’s main event loop; executing an undo operation reverts all changes that occurred during the cycle. When performing an undo operation, an undo manager saves the operations that were reverted so that users can redo what has been undone.

Undo and Redo Operations Are Put on Stacks


An undo manager stores undo and redo operations on first-in last-out stacks. When an application first registers an undo operation, the undo manager adds it to the undo stack. The redo stack, however, remains empty until the user requests an undo operation. When that happens, the undo manager uses the topmost group of operations on the undo stack tocompose and send one or more messages to revert changes.

  Since these operations again cause changes to one or more object’s state, the objects register new operations with the undo manager, this time in thereverse direction from theoriginal operations. Because the undo manager is currently undoing changes, it records these operations as redo operations on the redo stack.Subsequent redo operations pull the operations off the redo stack, apply them to the objects, and push them back onto the undo stack. Because a new change to an object’s stateinvalidates the previous change, as soon as a new undo operation is registered, an undo manager clears the redo stack.

Operations Are Coalesced into Undo Groups


  An undo manager collects undo and redo operations in groups that represent actions that are entirely revertible. A group typically identifies properties that are related in some way. It stores these groups of operations as items on the undo and redo stacks. Even a single action must be packaged as a group. NSUndoManager normally creates undo groups automatically during a cycle of the run loop. The first time it is asked to record an undo operation in the cycle, it creates a new group. Then, at the end of the cycle, it closes the group. You can createadditional,nested undo groups.

How to Register and Request Undo and Redo Operations


  The NSUndoManager class gives you two ways to register undo operations:
For simple registration, call registerUndoWithTarget:selector:object:, which takes a target object, a selector, and a single argument.
For invocation-based registration, call prepareWithInvocationTarget:, passing in a NSInvocation object thatencapsulates the message to send for reverting changes. With thisapproach you can have any number and type of arguments.
You often call these methods in the accessor method for a property of an object that is being changed. To request an undo or redo operation, send undo or redo message to a NSUndoManager object.

The Undo Manager and the Responder Chain


  The responder chain plays an important role in undo management, especially when more than the default undo manager is in play. The responder class in either the UIKit or AppKit frameworks (UIResponder or NSResponder) declares the undoManager property and undoManagermethod, respectively. When an application receives an undo event, the responder class starts with the first responder and from there goes up the responder chain looking for an NSUndoManager object (through the undoManager property or method). If the end of the responder chain is reached, the window object creates and returns the default undo manager.

  If you want an undo manager for a specific context in addition to the default undo manager, your responder subclass can implement the undoManager property or method to create and return one. The responder subclass is often a custom view but it can also be, on iOS, a view controller (which must ensure that it becomes first responder). In OS X, the delegate of a window object can implement the windowWillReturnUndoManager: to return an undo manager.

The User Interface for Requesting Undo and Redo


  Users request undo and redo operations in OS X and iOS in different ways. In a Mac app, the user chooses an Undo or Redo menu command from the Edit menu. In an iOS application, the user shakes the device. For a shaking motion to function as command, the applicationSupportsShakeToEdit property of UIApplication must be set to YES and there must be an undo manager in anappropriate state. If these conditions apply, the application displays an alert view with buttons for undo and redo. In both iOS and OS X, you can give specific action names to undo and redo commands—for example, Undo Color Change.

2.2 生词

undo[ʌn'duː]vt. 取消;解开;破坏;扰乱

upon[ə'pɒn]prep. 根据;接近;在…之上

conduct['kɒndʌkt]vt. 管理;引导;表现

redo[riː'duː]vt. 重做;重新装饰

revert[rɪ'vɜːt]vi. 回复;重提;返祖遗传;归还

original[ə'rɪdʒɪn(ə)l; ɒ-]adj. 原始的;最初的;独创的;新颖的

valuable['væljʊb(ə)l]adj. 有价值的;贵重的;可估价的

especially[ɪ'speʃ(ə)lɪ; e-]adv.特别;尤其;格外

extensively[ik'stensivli]adv.广阔地;广大地

obtain[əb'teɪn]vi. 获得;流行

composed[kəm'pəʊzd]v. 组成;作曲(compose的过去分词);著作

components[kəm'pəunənt]n. 部件;组件;成份(component复数)

registration[redʒɪ'streɪʃ(ə)n]n.登记;注册;挂号

signature['sɪgnətʃə]n. 署名;签名;信号

reverse[rɪ'vɜːs]vt. 颠倒;倒转

original[ə'rɪdʒɪn(ə)l; ɒ-]adj. 原始的;最初的;独创的;新颖的

subsequent['sʌbsɪkw(ə)nt]adj.后来的,随后的

invalidate[ɪn'vælɪdeɪt]vt.使无效;使无价值

coalesce[,kəʊə'les]vi. 合并;结合;联合

represent[reprɪ'zent]vt.代表;表现

entirely[ɪn'taɪəlɪ; en-]adv.完全地,彻底地

revertible[ri'və:təbl]adj. 应归还的;可恢复原状的

additional[ə'dɪʃ(ə)n(ə)l]adj.附加的,额外的

nested['nestɪd]adj. 嵌套的,内装的

encapsulate[ɪn'kæpsjʊleɪt; en-]vt. 压缩;将…装入胶囊;将…封进内部

approach[ə'prəʊtʃ]n. 方法;途径;接近

respectively[rɪ'spektɪvlɪ]adv. 分别地;各自地,独自地

ensure[ɪn'ʃɔː; -'ʃʊə; en-]vt.保证,确保;使安全

appropriate[ə'prəʊprɪət]adj.适当的

3 结语

  以上是所有内容,希望对大家有所帮助。

这篇关于IT English Collection(26) of Undo manager的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/957158

相关文章

查看Oracle数据库中UNDO表空间的使用情况(最新推荐)

《查看Oracle数据库中UNDO表空间的使用情况(最新推荐)》Oracle数据库中查看UNDO表空间使用情况的4种方法:DBA_TABLESPACES和DBA_DATA_FILES提供基本信息,V$... 目录1. 通过 DBjavascriptA_TABLESPACES 和 DBA_DATA_FILES

Linux下MySQL8.0.26安装教程

《Linux下MySQL8.0.26安装教程》文章详细介绍了如何在Linux系统上安装和配置MySQL,包括下载、解压、安装依赖、启动服务、获取默认密码、设置密码、支持远程登录以及创建表,感兴趣的朋友... 目录1.找到官网下载位置1.访问mysql存档2.下载社区版3.百度网盘中2.linux安装配置1.

Collection List Set Map的区别和联系

Collection List Set Map的区别和联系 这些都代表了Java中的集合,这里主要从其元素是否有序,是否可重复来进行区别记忆,以便恰当地使用,当然还存在同步方面的差异,见上一篇相关文章。 有序否 允许元素重复否 Collection 否 是 List 是 是 Set AbstractSet 否

ORACLE 11g 创建数据库时 Enterprise Manager配置失败的解决办法 无法打开OEM的解决办法

在win7 64位系统下安装oracle11g,在使用Database configuration Assistant创建数据库时,在创建到85%的时候报错,错误如下: 解决办法: 在listener.ora中增加对BlueAeri-PC或ip地址的侦听,具体步骤如下: 1.启动Net Manager,在“监听程序”--Listener下添加一个地址,主机名写计

浅谈PHP5中垃圾回收算法(Garbage Collection)的演化

前言 PHP是一门托管型语言,在PHP编程中程序员不需要手工处理内存资源的分配与释放(使用C编写PHP或Zend扩展除外),这就意味着PHP本身实现了垃圾回收机制(Garbage Collection)。现在如果去PHP官方网站(php.net)可以看到,目前PHP5的两个分支版本PHP5.2和PHP5.3是分别更新的,这是因为许多项目仍然使用5.2版本的PHP,而5.3版本对5.2并不是完

DAY16:什么是慢查询,导致的原因,优化方法 | undo log、redo log、binlog的用处 | MySQL有哪些锁

目录 什么是慢查询,导致的原因,优化方法 undo log、redo log、binlog的用处  MySQL有哪些锁   什么是慢查询,导致的原因,优化方法 数据库查询的执行时间超过指定的超时时间时,就被称为慢查询。 导致的原因: 查询语句比较复杂:查询涉及多个表,包含复杂的连接和子查询,可能导致执行时间较长。查询数据量大:当查询的数据量庞大时,即使查询本身并不复杂,也可能导致

Collection的所有的方法演示

import java.util.ArrayList;import java.util.Collection;import java.util.Iterator;public class TestCollection {/*** @param args* Collection的所有的方法演示* 此程序没有使用泛型,所以可以添加任意类型* 以后如果写到泛型会补充这一方面的内容*/public s

redo undo 和 binlog 有什么作用

MySQL中有六种日志文件, 分别是:重做日志(redo log)、回滚日志(undo log)、二进制日志(binlog)、错误日志(errorlog)、慢查询日志(slow query log)、一般查询日志(general log),中继日志(relay log)。 其中重做日志和回滚日志与事务操作息息相关,二进制日志也与事务操作有一定的关系,这三种日志,对理解MySQL中的事务操作有着重要

Oracle Enterprise Manager:Oracle数据库管理的高效工具

在数据库管理和维护中,Oracle Enterprise Manager(OEM)是一个强大的工具,它提供了一个集中的平台来监控、管理和优化Oracle数据库环境。通过使用Oracle Enterprise Manager,数据库管理员可以提高效率、减少手动干预并确保数据库系统的稳定性和性能。本文将详细介绍如何在Oracle中使用Oracle Enterprise Manager,包括其主要功能、

Mybatis的collection只显示一条数据

在mybatis一对多映射中,多的那种表mybatis只查询出一条数据,而直接用sql查询数据库的话有多条数据。这是因为两张表的主键同名,都为id_key。解决方法:使用别名。给映射多的那张表的主键使用别名。 sql语句别名 resultmap映射