简体   繁体   中英

Why NSInvocation

Why use NSInvocation when you could just call the method? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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