简体   繁体   English

如何编码一个NSInvocation?

[英]How to encode a NSInvocation?

我可以通过添加<NSCoding>方法的类别来解决此问题吗?

While Joshua's answer is correct, there is a meta-answer. 虽然约书亚的答案是正确的,但有一个元答案。

You really don't want to archive an NSInvocation . 您真的不想存档NSInvocation An NSInvocation may contain an arbitrary target, may have been invoked and have an arbitrary return value, and might have any number of arbitrary arguments. NSInvocation可以包含任意目标,可以被调用并具有任意返回值,并且可以具有任意数量的任意参数。 Generic archiving is pretty much entirely out of the question. 通用归档几乎完全不可能。

You are far better off architecting our app such that you archive exactly the set of state you need to recreate an appropriately configured invocation upon unarchival. 您最好对我们的应用程序进行架构设计,以便准确地存档在取消存档时重新创建适当配置的调用所需的状态集。

Have you tried the documentation ? 您是否尝试过文档 It says: 它说:

Note: NSInvocation conforms to the NSCoding protocol, but only supports coding by an NSPortCoder. 注意: NSInvocation符合NSCoding协议,但仅支持通过NSPortCoder进行编码。 NSInvocation does not support archiving. NSInvocation不支持存档。

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

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