Search code examples
iphoneobjective-c++

Private Methods in ObjC++


I need to rename a ObjC Class Implementation File into *.mm, because I'm using a C++ Framework (Box2D). After renaming the file and setting the Filetype to "sourcecode.cpp.objcpp" my following declaration of private methods produces some errors like:

error: expected identifier before 'private'

The declaration of methods:

@interface GameplayLayer(private)
 - (void)spawnTick:(ccTime)delta;
 - (void)pushSpawnTick;
@end

How can I use declarations of private methods in ObjC++?


Solution

  • It is probably because private is a keyword in C++. You can either change it to something else like hidden or leave the category name empty (this is called a 'class continuation', you can read more about it by searching in this article.)