This feature was already in Objective-C. The main purpose of this feature is data hiding or data privacy.
If you want to use some private variables that cannot be accessed outside the class, you can go with a category, in particular a .m file.
Even in Xcode 4.3.2, when you create a new class, then the default .m file contains one category by default. (just before implementation).
ViewController.m **@interface ViewController () @end** @implementation ViewController .......
In this interface you can declare your private members. And you can use them simply with [self variableName] in the entire .m file.
Similarly, you can declare your private methods in the same category.
So, your instance object created outside the class file cannot read these variables and methods.
Hope this is what you are looking for.
Enjoy the coding :)
source share