Search code examples
objective-clanguage-featuresabstraction

Objective-C: how to prevent abstraction leaks


I gather that in Objective-C I must declare instance variables as part of the interface of my class even if these variables are implementation details and have private access.

In "subjective" C, I can declare a variable in my .c file and it is not visible outside of that compilation unit. I can declare it in the corresponding .h file, and then anyone who links in that compilation unit can see the variable.

I wonder if there is an equivalent choice in Objective-C, or if I must indeed declare every ivar in the .h for my class.

Ari.


Solution

  • Ari,

    A good reference to how to accomplish "invisible" instance variable declarations can be found here with credit respectfully given to Matt Gallagher.

    Hope it helps, Frank