Reputation: 2853
I am trying to create a weak reference of a .mm class... the problem is the file even though code-wise its a NSObject class it considers it as a int* type. If I change the file back to .m though it accepts it as a Obj-c class but the code stops working because of cocos2d requirement of files being .mm
//Game Logic is actually NSObject meaning obj-c class.
@interface GameLogic : NSObject
//However here I get the error like the file is type int*
@property (weak,nonatomic)GameLogic * __weak gameLogicWeak;
Those are the 2 msgs I get.
Property with 'weak' attribute must be of object type
'__weak' only applies to Objective-C object or block pointer types; type here is 'int *'
Anyone has any idea what can I do to overcome this problem? I know there exists many solutions, one of them would be just not create that weak link, use delegate, or well many other possible solutions.
But this solution was a cleaner one that I came up with which makes ARC come in handy with the memory clean up.
Any suggestions? Workarounds? Solutions? anyone has come with this problem?
====
I get the following message when @class GameLogic is added in .h and #import in the .m respectively. This message is generated in a location where I am using the weak reference.
Receiver type 'GameLogic' for instance message is a forward declaration
Upvotes: 1
Views: 465
Reputation: 64477
Did you do
#import "GameLogic.h"
in the header where you added the property? You can also add
@class GameLogic;
but not
class GameLogic;
because that would make it a forward reference to a C++ class. Also double-check that you don't actually have a C++ class of the same name.
And is that header file's implementation also .mm? Because it has to be if GameLogic allows direct access (property or return value) to a C++ class.
Upvotes: 1