What does @private
mean in Objective-C?
Ios – What does “@private” mean in Objective-C
cocoaiosobjective cprivate
Related Topic
- Objective-c – Shortcuts in Objective-C to concatenate NSStrings
- Ios – Constants in Objective-C
- Ios – What’s the difference between the atomic and nonatomic attributes
- Objective-c – a typedef enum in Objective-C
- Ios – Xcode – How to fix ‘NSUnknownKeyException’, reason: … this class is not key value coding-compliant for the key X” error
- Php – the difference between public, private, and protected
- Ios – What does the “__block” keyword mean
- Swift – How to call Objective-C code from Swift
Best Answer
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:
Also, to clarify, methods are always public in Objective-C. There are ways of "hiding" method declarations, though—see this question for more information.