I am new to Objective-C, and I found that the practice of declaring ivars in the header is very strange. This means declaring the internal state of an object in its public heading, which contradicts the concept of encapsulation.
For example, you have an iPad. Apple does not want you to violate the iPad, open and peep, and tinker with the items inside. If they want you to change something, the iPad will have a setting that allows you to change it.
Similarly, I do not want other programmers to see ivars of my objects. His inner state is my object. If I want you to achieve an inner state, I will declare properties for it.
So, as in other languages, I would hide my ivars inside the implementation file and not declare them in the header.
The ivars ad in the title just amazes me very weirdly. These ivars are implementation specific and should not just be part of the header file.
Leander 09 Oct '12 at 9:05 2012-10-09 09:05
source share