Why does the ARC migrator say that NSInvocation's -setArgument: is not safe unless the argument is __unsafe_unretained?

后端 未结 6 768
离开以前
离开以前 2020-12-25 12:07

I was migrating a block of code to automatic reference counting (ARC), and had the ARC migrator throw the error

NSInvocation\'s setArgument is not sa

6条回答
  •  星月不相逢
    2020-12-25 12:50

    According to Apple Doc NSInvocation:

    This class does not retain the arguments for the contained invocation by default. If those objects might disappear between the time you create your instance of NSInvocation and the time you use it, you should explicitly retain the objects yourself or invoke the retainArguments method to have the invocation object retain them itself.

提交回复
热议问题