How to encode a NSInvocation?
Can I fix this with adding a category of <NS开发者_开发问答Coding>
methods ?
While Joshua's answer is correct, there is a meta-answer.
You really don't want to archive an 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. 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 does not support archiving.
精彩评论