7

Does Cocos2d have any naming conventions for variables?

I have this

//.h
NSMutableArray *newRowForCounter;

and

//.m
@synthesize newRowForCounter;

At @synthesize it's warning me that "property's synthesized getter follows cocoa naming convention for returning 'owned' objects". If I change the name to something else, it work fine.

1

2 Answers 2

48

new cannot be used in the variable name at the beginning. That is why it shows the error.

Sol : declare a property whose name begins with new unless you specify a different getter:

// Won't work:
@property NSString *newTitle;

// Works:
@property (getter=theNewTitle) NSString *newTitle;

Explanations here and here

0
0

You can added an NS_RETURNS_NOT_RETAINED attribute to your property declaration to tell the compile that an 'owned' object is not returned here despite the "new" prefix in the property name, as follows:

@property (nonatomic, copy) NSMutableArray *newRowForCounter NS_RETURNS_NOT_RETAINED;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.