0

I am a calling c++ method from objective c:

C++ Method:

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

Objective C:

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

     TestMethod( outputSize, [outputArray getArray ]);
}

How do I accomplish this? I hear from other postings that objective-c does not support pass by reference.

ssk
  • 9,045
  • 26
  • 96
  • 169
  • Undo is right, here is a good example http://stackoverflow.com/questions/2892520/passing-arguments-by-value-or-by-reference-in-objective-c – Eugene Gordin Apr 25 '13 at 04:59

2 Answers2

1

You should be able to - Obj-C is a strict subset of C. Just make sure that the file the code is in is a .mm file - not just .m

Undo
  • 25,519
  • 37
  • 106
  • 129
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.

newacct
  • 119,665
  • 29
  • 163
  • 224