1.. title:: clang-tidy - objc-nsinvocation-argument-lifetime 2 3objc-nsinvocation-argument-lifetime 4=================================== 5 6Finds calls to ``NSInvocation`` methods under ARC that don't have proper 7argument object lifetimes. When passing Objective-C objects as parameters 8to the ``NSInvocation`` methods ``getArgument:atIndex:`` and 9``getReturnValue:``, the values are copied by value into the argument pointer, 10which leads to incorrect releasing behavior if the object pointers are 11not declared ``__unsafe_unretained``. 12 13For code: 14 15.. code-block:: objc 16 17 id arg; 18 [invocation getArgument:&arg atIndex:2]; 19 20 __strong id returnValue; 21 [invocation getReturnValue:&returnValue]; 22 23The fix will be: 24 25.. code-block:: objc 26 27 __unsafe_unretained id arg; 28 [invocation getArgument:&arg atIndex:2]; 29 30 __unsafe_unretained id returnValue; 31 [invocation getReturnValue:&returnValue]; 32 33The check will warn on being passed instance variable references that have 34lifetimes other than ``__unsafe_unretained``, but does not propose a fix: 35 36.. code-block:: objc 37 38 // "id _returnValue" is declaration of instance variable of class. 39 [invocation getReturnValue:&self->_returnValue]; 40