Private methods in ObjC ++

I need to rename the implementation file of the ObjC class to * .mm because I use the C ++ Framework (Box2D). After renaming the file and setting Filetype to "sourcecode.cpp.objcpp" my following private method declaration causes some errors, for example:

error: expected identifier before 'private'

Method Declaration:

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

How can I use private method declarations in ObjC ++?

+3
source share
2 answers

, , private - ++. - , hidden, ( , .)

+5

Obj-C .m ,

//this is A.h

@interface A

- (void) publicMethod1;

@end



//this is A.m

@interface A ()

- (void) privateMethod1;

@end

@implementation A

- (void) publicMethod1
{
    //foo
}

- (void) privateMethod1
{
    //foo
}

@end
+3

Source: https://habr.com/ru/post/1762656/


All Articles