简体   繁体   English

为何选择NSInvocation

[英]Why NSInvocation

Why use NSInvocation when you could just call the method? 为什么在可以调用方法时使用NSInvocation? Need to ask this question because I can't understand the need to use this class. 需要问这个问题,因为我无法理解使用这个类的必要性。 What is the advantage of using it over just calling the method like below. 使用它而不仅仅是调用下面的方法有什么好处。

 [myArray addObject:myString];

Additional info: What specific challenges does it resolve/address which can't be addressed by the other method calling options. 附加信息:它解决/解决哪些具体挑战,其他方法调用选项无法解决。

One use: You could use it to implement a chain of undo actions - where each different action would be a different method call to undo. 一个用途:您可以使用它来实现一系列撤消操作 - 其中每个不同的操作都是对撤消的不同方法调用。 You would encapsulate each undo action as a method call wrapped in an NSInvocation object. 您可以将每个撤消操作封装为包含在NSInvocation对象中的方法调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM