0

我是来自目标 c 的调用 c++ 方法:

C++ 方法:

void TestMethod( size_t& outputSize,
                 OutputArray& outputArray );

目标 C:

-(void) testMethodObjc : outputSize,
       OutputArrayObjc : outputArray
{

     TestMethod( outputSize, [outputArray getArray ]);
}

我该如何做到这一点?我从其他帖子中听说objective-c 不支持通过引用传递。

4

2 回答 2

1

Objective-C, like C, does not support pass by reference.

Like C, you can take the address of the variable and pass a pointer instead. And to manipulated the original variable in the function you would need to dereference the pointer.

于 2013-04-25T22:36:23.403 回答
1

您应该能够 - Obj-C 是 C 的严格子集。只要确保代码所在的文件是一个.mm文件 - 而不仅仅是.m

于 2013-04-24T22:37:34.430 回答