-1

I'm trying to declare a private property but I'm getting this error:

Unexpected '@' in program

Here is my implementation

@implementation MyClassImplementation

@property (nonatomic,strong) NSArray *new;

@end

Here is where I get the error @property (nonatomic,strong) NSArray *new; any of you knows why I'm getting this error or if there is a work around this?

I'll really appreciate your help

user2924482
  • 8,380
  • 23
  • 89
  • 173
  • 1
    Does this answer your question? [private property in Objective C](https://stackoverflow.com/questions/5643130/private-property-in-objective-c) – dandan78 Jul 21 '20 at 18:30

1 Answers1

3

Private properties usually are declared in .m file in class unnamed category and for following Cocoa naming convention shouldn't use new keyword:

@interface MyClassImplementation ()

@property (nonatomic, strong) NSArray *array;

@end

@implementation MyClassImplementation

....

@end
iUrii
  • 11,742
  • 1
  • 33
  • 48
  • 1
    For the sake of correct terminology, `@interface MyClassImplementation ()` is NOT unnamed/anonymous category, but it's a class extension. See [Class Extensions Extend the Internal Implementation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html#//apple_ref/doc/uid/TP40011210-CH6-SW3). – zrzka Jul 21 '20 at 18:35
  • @zrzka Thanks for your notice but from the doc: "Because no name is given in the parentheses, class extensions are often referred to as anonymous categories." so it can be named this way. – iUrii Jul 21 '20 at 18:41