Cannot understand NSError/NSObject pointer passing behavior

前端 未结 2 1784
花落未央
花落未央 2021-01-05 17:13

I am now confused by pointer to pointer even though I\'ve read Why does NSError need double indirection? (pointer to a pointer) and NSError * vs NSError ** and much more.

2条回答
  •  春和景丽
    2021-01-05 18:05

    The variable in the caller has type NSError*. The address has type NSError* *. The function expect NSError* __autoreleasing *. Therefore the compiler creates a hidden variable of type NSError* __autoreleasing, copies the NSError* into the hidden variable before the call, and copies it back after the call to get the semantics of __autoreleasing right.

提交回复
热议问题