Ios – What does “@private” mean in Objective-C


What does @private mean in Objective-C?

Best Solution

It's a visibility modifier—it means that instance variables declared as @private can only be accessed by instances of the same class. Private members cannot be accessed by subclasses or other classes.

For example:

@interface MyClass : NSObject
    int someVar;  // Can only be accessed by instances of MyClass

    int aPublicVar;  // Can be accessed by any object

Also, to clarify, methods are always public in Objective-C. There are ways of "hiding" method declarations, though—see this question for more information.